Re: Parsing XML with namespaces in IE.
On Nov 3, 1:03 pm, Martin Honnen <mahotr...@yaho o.dewrote:
Thank you Martin for a helpful reply. I have now got IE reading the
XML thanks to your post.
Regards,
Steve
On Nov 3, 1:03 pm, Martin Honnen <mahotr...@yaho o.dewrote:
With IE you use MSXML for XML DOM, it implements methods selectNodes and
selectSingleNod e for DOM documents and elements (or even nodes in
general). With MSXML 3 and later you can pass an XPath 1.0 expression to
those two methods to select nodes:
var doc = new ActiveXObject(' Msxml2.DOMDocum ent.3.0');
doc.async = false;
if (doc.load('file .xml'))
{
// necessary for MSXML 3 first:
doc.setProperty ('SelectionLang uage', 'XPath');
>
// now bind prefixes to namespace URIs e.g.
doc.setProperty ('SelectionName spaces',
'xmlns:pf1="htt p://example.com/ns1" xmlns:pf2="http ://example.org/ns2"');
>
// and use those prefixes in XPath expresssions
var nodeList = doc.selectNodes ('pf1:foo/pf1:bar/pf2:baz');
// use nodeList here
}
selectSingleNod e for DOM documents and elements (or even nodes in
general). With MSXML 3 and later you can pass an XPath 1.0 expression to
those two methods to select nodes:
var doc = new ActiveXObject(' Msxml2.DOMDocum ent.3.0');
doc.async = false;
if (doc.load('file .xml'))
{
// necessary for MSXML 3 first:
doc.setProperty ('SelectionLang uage', 'XPath');
>
// now bind prefixes to namespace URIs e.g.
doc.setProperty ('SelectionName spaces',
'xmlns:pf1="htt p://example.com/ns1" xmlns:pf2="http ://example.org/ns2"');
>
// and use those prefixes in XPath expresssions
var nodeList = doc.selectNodes ('pf1:foo/pf1:bar/pf2:baz');
// use nodeList here
}
XML thanks to your post.
Regards,
Steve
Comment