Hi,
My xml document uses different namespaces:
<x:root xmlns:x="x:ns:m eta/">
<element1 xmlns:adam="htt p://ns.alfaprint.be/">
</root>
This gives problems when using an XPath query.
I already created 2 namespace managers
XmlNamespaceMan ager mgr1 = new
XmlNamespaceMan ager(oXmlDocume nt.NameTable);
mgr1.AddNamespa ce("x", "x:ns:meta" );
XmlNamespaceMan ager mgr2 = new XmlNamespaceMan ager(new NameTable());
mgr2.AddNamespa ce("adam", "http://ns.alfaprint.be/");
I tried the following 2 things:
XmlNode oXmlNode =
oXmlRoot.Select SingleNode("//x:Root[@xmlns:adam='ht tp://ns.alfaprint.be/']",
mgr1);
This statement returns oXmlNode to be null;
XmlNode oXmlNode =
oXmlRoot.Select SingleNode("//x:Root[@xmlns:adam='ht tp://ns.alfaprint.be/']",
mgr2);
This returns an exception telling that the namespace of the root
element is not declared.
Does anyone can help me on this?
Thanks in advance. Kind regards,
Karine Bosch
My xml document uses different namespaces:
<x:root xmlns:x="x:ns:m eta/">
<element1 xmlns:adam="htt p://ns.alfaprint.be/">
</root>
This gives problems when using an XPath query.
I already created 2 namespace managers
XmlNamespaceMan ager mgr1 = new
XmlNamespaceMan ager(oXmlDocume nt.NameTable);
mgr1.AddNamespa ce("x", "x:ns:meta" );
XmlNamespaceMan ager mgr2 = new XmlNamespaceMan ager(new NameTable());
mgr2.AddNamespa ce("adam", "http://ns.alfaprint.be/");
I tried the following 2 things:
XmlNode oXmlNode =
oXmlRoot.Select SingleNode("//x:Root[@xmlns:adam='ht tp://ns.alfaprint.be/']",
mgr1);
This statement returns oXmlNode to be null;
XmlNode oXmlNode =
oXmlRoot.Select SingleNode("//x:Root[@xmlns:adam='ht tp://ns.alfaprint.be/']",
mgr2);
This returns an exception telling that the namespace of the root
element is not declared.
Does anyone can help me on this?
Thanks in advance. Kind regards,
Karine Bosch
Comment