getting text out of an xml string

John Machin sjmachin at lexicon.net
Fri Mar 4 15:30:22 EST 2011


On Mar 5, 6:53 am, JT <jeff.temp... at gmail.com> wrote:
> Yo,
>
>  So I have almost convinced a small program to do what I want it to
> do.  One thing remains (at least, one thing I know of at the moment):
> I am converting xml to some other format, and there are strings in the
> xml like this.
>
> The python:
>
> elif v == "content":
>                 print "content", a.childNodes[0].nodeValue
>
> what gets printed:
>
> content \u3c00note xml:space="preserve"\u3e00see forms in red inbox
> \u3c00/note\u3e00
>
> what this should say is "see forms in red inbox" because that is what
> the the program whose xml file i am trying to convert, properly
> displays, because that is what I typed in oh so long ago.  So my
> question to you is, how can I convert this "enhanced" version to a
> normal string?  Esp. since there is this "xml:space="preserve"" thing
> in there ... I suspect the rest is just some unicode issue.  Thanks
> for any help.
>
>        J "long time no post" T

Your data has been FUABARred (the first A being for Almost) -- the
"\u3c00" and "\u3e00" were once "<" and ">" respectively. You will
need to show (a) a snippet of the xml file including the data that has
the problem (b) the code that you have written, cut down to a small
script that is runnable and displays the problem. Tell us what version
of Python you are running, on what OS.



More information about the Python-list mailing list