1 May 19:41
Ingore namespace when parsing
Aaron Maxwell <amax <at> redsymbol.net>
2009-05-01 17:41:19 GMT
2009-05-01 17:41:19 GMT
Hi all,
When using python lxml to parse an XML document whose root element
defines a namespace, is there some way the library can allow me to not
explicitly invoke that namespace in queries?
Consider an XML document with this content:
{{{
<?xml version="1.0" ?>
<Root xmlns="http://redsymbol.net/SomeNamespace">
<Child1></Child1>
<Child2></Child2>
</Root>
}}}
If I parse it like this:
{{{
def ignore_ns(path_to_file):
x = etree.parse(open(path_to_file))
for kid in x.getroot():
print kid.tag
}}}
... where the path_to_file contains the above xml document, then this
output is produced:
{{{
{http://redsymbol.net/SomeNamespace}Child1
{http://redsymbol.net/SomeNamespace}Child2
}}}
(Continue reading)
RSS Feed