[moby] [MOBY-l] Perl API: conversion of node content to and from XML
Mark Wilkinson
mwilkinson at mrl.ubc.ca
Tue Mar 8 04:38:25 UTC 2005
Thanks for the fix! It is now committed to the CVS - let me know if it
still causes problems.
Cheers!
M
On Mon, 2005-03-07 at 03:48, Neerincx, Pieter wrote:
> Hi all,
>
> I'm pretty new to BioMOBY and have a question about the Perl API. I have some problems with extracting text data from objects like for example the String object. I have something like this:
>
> <String namespace='my.test.ns' id='0001' articleName='query'>some text & more text</String>
>
> The plain text contains for example "&" which has a special meaning in XML. Therefore I have to encode it using "&". If I use the getNodeContentWithArticle sub from CommonSubs.pm it serializes the data resulting in raw XML. Hence the result contains the "&" still encoded as "&". The same thing happens with encoded quotes. If I would be using the extractRawContent sub that would make sense to me. Off course I can convert the encoded stuff from and to raw XML manually, but wouldn't it be nicer if the API would take care of that? Or am I missing something here and is there a good reason the have for example the getNodeContentWithArticle sub return raw XML?
>
> If I change the code like this:
>
> sub getNodeContentWithArticle {
>
> ### lot's of other stuff ... ###
>
> # Using ->toString results in raw XML and will
> # not map encoded chars like '&' back to '&'.
> # Fetching node content using -> data will.
> #$resp .= $_->toString;
> $resp .= $_->data;
>
> ### lot's of other stuff ... ###
>
> }
>
> decoding the raw XML is taken care of by the API. Any feedback would be appriciated.
>
> Regards,
>
> Pieter Neerincx
>
> _______________________________________________
> moby-l mailing list
> moby-l at biomoby.org
> http://biomoby.org/mailman/listinfo/moby-l
--
Mark Wilkinson
Assistant Professor (Bioinformatics)
Dept. Medical Genetics, UBC, Canada
More information about the moby-l
mailing list