Forum Discussion

thebick's avatar
thebick
Occasional Contributor
4 years ago
Solved

SelectSingleNode not finding XML nodes; trying to setProperty("SelectionNamespaces", ...)

I am trying to use SelectSingleNode() to find any node other than the root for this XML:     <?xml version="1.0?> <myRootNode xmlns:xsl="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http:...
  • thebick's avatar
    4 years ago

    Finally figured out how the SelectionNamespaces stuff works:  

    doc.setProperty("SelectionNamespaces", "xmlns:<your_abbreviation>=<your_namespace>"

    which can then be used as

    nodeToFind = parentNode.SelectSingleNode("<your_abbreviation>:<tag1>/<your_abbreviation>:<tag2>")

    I need "<your_abbreviation>:" at all levels, because the namespace is at the root. In my case

    doc.setProperty('SelectionNamespaces', 'xmlns:abbrev="my:set:of:coloned:stuff"')
    L3N1 = root.SelectSingleNode("abbrev:level1Node1")

    works, adding "abbrev" and dropping the leading "/"