O
Omar
Hi,
I would use your help parsing an XML file. I am new to XPath, and I
would like to use it parsing an XML file generated with dia, the file looks
like :
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
<dia:diagramdata>
<dia:attribute name="background">
<dia:color val="#ffffff"/>
</dia:attribute>
<dia:attribute name="pagebreak">
<dia:color val="#000099"/>
</dia:attribute>
</dia:diagramdata>
</dia:diagram>
I would need to match all the "attribute" nodes. I don't know wether the
XPath expression i'm using is wrong or whether the API (libxml2) i'm using
is loosy ...
Trying "//attribute" matches nothing, "//dia:attribute" gives the following
libxml error : "XPath error : Undefined namespace prefix" and the wierdest
thing is that :
"//*" matches all nodes with no errors... "/*" matches the "diagram" node
with no errors but ... "/diagram" matches nothing and neither does
"/dia:diagram" which actually gives the "XPath error : Undefined namespace
prefix". Can anyone help me !
Thanks in advance.
I would use your help parsing an XML file. I am new to XPath, and I
would like to use it parsing an XML file generated with dia, the file looks
like :
<?xml version="1.0" encoding="UTF-8"?>
<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
<dia:diagramdata>
<dia:attribute name="background">
<dia:color val="#ffffff"/>
</dia:attribute>
<dia:attribute name="pagebreak">
<dia:color val="#000099"/>
</dia:attribute>
</dia:diagramdata>
</dia:diagram>
I would need to match all the "attribute" nodes. I don't know wether the
XPath expression i'm using is wrong or whether the API (libxml2) i'm using
is loosy ...
Trying "//attribute" matches nothing, "//dia:attribute" gives the following
libxml error : "XPath error : Undefined namespace prefix" and the wierdest
thing is that :
"//*" matches all nodes with no errors... "/*" matches the "diagram" node
with no errors but ... "/diagram" matches nothing and neither does
"/dia:diagram" which actually gives the "XPath error : Undefined namespace
prefix". Can anyone help me !
Thanks in advance.