1

I am trying to access the contents of the path below:

/newsMessage/itemSet/newsItem[2]/contentSet/remoteContent[3]/rtr:altId

However, the path is not being accepted due to the colon, is there any way to escape this character or make the contents of this path accessible.

I have tried using something similar to this:

/*[name()='rtr:altId']

however I'm unsure where I would put this in the CSS and if I have formatted correctly.

Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
user48290
  • 11
  • 1
  • You will find many posts on this subject. You need to declare the prefix used in your XPath expression from the calling API, and the details depend on what XPath API you are using, which you haven't told us. I linked to an answer relevant to PHP, but you will find the same question asked for many other APIs and the answer is usually very similar. – Michael Kay Dec 09 '22 at 14:42
  • @MichaelKay: Since OP didn't mention a language, I've changed the PHP-based duplicate link to the canonical answer I wrote to [How does XPath deal with XML namespaces?](https://stackoverflow.com/q/40796231/290085) -- it covers nearly all languages/APIs. – kjhughes Dec 09 '22 at 15:59

1 Answers1

0

Try this:

/newsMessage/itemSet/newsItem[2]/contentSet/remoteContent[3]/*[name()="altId"]

or

/newsMessage/itemSet/newsItem[2]/contentSet/remoteContent[3]/*[local-name()="altId"]
Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223