Reputation: 1014
I have the following xml document.
<?xml version="1.0" encoding="UTF-8"?>
<LevelOne>
<LevelTwo>
<LevelThree class="MyClass">
<Property name="FirstName">hello</Property>
<Property name="SecondName">bar</Property>
<Property name="ThirdName">world</Property>
<Property name="FourthName">foo</Property>
</LevelThree>
</LevelTwo>
</LevelOne>
When I run the following xPath query,
xpath my.xml //Property
Gives me the following results where all the nodes are selected.
Now, I want to select the node where the name attribute of the node is equal to FirstName. I came up with following xPath query after going through some examples on the internet.
xpath my.xml //Property[@name='FirstName']
And I end up getting the following result on both macOS and Ubuntu terminals.
What am I possibly doing wrong here?
Upvotes: 1
Views: 150
Reputation: 1014
As pointed out in @Robby Cornelissen's answer, the issue seems to be with the quotations. Wrapping the query inside quotations as follows solved the problem.
xpath my.xml "//Property[@name='FirstName']"
Upvotes: 1