1

I'm trying to come up with an XPath expression for the COL node in the following XML document:

<?xml version="1.0" encoding="US-ASCII"?>
<RESP
    xmlns="urn:brown.trout.com">
    <QR>
        <COL
            xmlns="urn:child.brown.trout.com">
            <names>Hello</names>
            <names>World</names>
        </COL>
    </QR>
</RESP>

The following XPath expression works:

/RESP/QR/*:COL

However, I'd prefer to have an expression that doesn't use the wildcard (*) character as performance is critical (performance is obviously not an issue for this trivial example - however, it is a concern for the actual application).

There's got to be straightforward way to reference without a wildcard?

  • 1
    You define a namespace prefix for each namespace and use it in the XPath. How you define a namespace prefix depends on the hosting language. See duplicate link for namespace prefix declaration methods of many hosting languages. – kjhughes Dec 02 '20 at 19:26
  • Thank you. This was killing me – Bobby Kenny Dec 02 '20 at 19:37

0 Answers0