0

I came across this XPath string...

courses[?(@.id==101)].students[?(@.id==111)]

I'm not even sure if it is valid XPath because of how '?' and '.' are used. And it doesn't work in many online XPath evaluators.

Although, in XPath 3, there is a lookup operator ('?') and some JSON scanning features. Refer: https://www.altova.com/training/xpath3/xpath-31#lookup-operator

So, I'm wondering what exactly the purpose of the '?()' and '.' are.

So far I'm guessing that this expression is being used to search into a JSON content within an XML.

Guessing the JSON object is like this:

{
    "courses":[
        {
            'id':'101', 
            'name':'Course 101', 
            'students':[
                { 
                    'id':'111', 
                    'name':'Student 111' 
                }
            ]
        }   
    ]
}

In short, is it a valid XPath 3 expression? And if yes, then what exactly are '?()' and '.' doing?

Teddy
  • 4,009
  • 2
  • 33
  • 55

1 Answers1

0

JSON can only work with double quotes

Vitalii
  • 113
  • 1
  • 1
  • 11