XML Parsing

harvey.thomas at informa.com harvey.thomas at informa.com
Wed Mar 28 06:22:26 EDT 2007


On Mar 28, 10:51 am, "Diez B. Roggisch" <d... at nospam.web.de> wrote:
> pyappl... at gmail.com wrote:
> > I want to parse this XML file:
>
> > <?xml version="1.0" ?>
>
> > <text>
>
> > <text:one>
> > <file>filename</file>
> > <contents>
> > Hello
> > </contents>
> > </text:one>
>
> > <text:two>
> > <file>filename2</file>
> > <contents>
> > Hello2
> > </contents>
> > </text:two>
>
> > </text>
>
> > This XML will be in a file called filecreate.xml
>
> > As you might have guessed, I want to create files from this XML file
> > contents, so how can I do this?
> > What modules should I use? What options do I have? Where can I find
> > tutorials? Will I be able to put
> > this on the internet (on a googlepages server)?
>
> > Thanks in advance to everyone who helps me.
> > And yes I have used Google but I am unsure what to use.
>
> The above file is not valid XML. It misses a xmlns:text namespace
> declaration. So you won't be able to parse it regardless of what parser you
> use.
>
> Diez- Hide quoted text -
>
> - Show quoted text -

The example is valid well-formed XML. It is permitted to use the ":"
character in element names. Whether one should in a non namespace
context is a different matter.

Harvey




More information about the Python-list mailing list