Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting nodes from a default namespace with msmxl Dom

XML 101

Selecting nodes from a default namespace with msmxl Dom

by  DrHeadgear  Posted    (Edited  )
Does your XML document have a default namespace? Do your selectNodes and selectSingleNode methods on your DOMDocument draw a blank?

Try this:

objDom.setProperty "SelectionNamespaces", "xmlns:newPrefix='myCurrentDefaultNamespace'"

objDom.selectNodes("//newPrefix:ThisNodeName")

What happens is that the dom object, being namespace aware, knows your nodes belong to your default namespace. But as you haven't declared that this namespace applies to nodes with a certain prefix you have no way of specifying which namespace the nodes you wish to select belong to. If you just use the node name in your selection then you will draw a blank; the dom object will assume you are asking for nodes with NO namespace.

The setProperty method allows you to assign a temporary prefix for the namespace and use it in your selection queries.

For more information about WHY these methods don't seem to work when there is a default namespace see JJR's FAQ: How to match nodes if there's a default namespace in the xml.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top