1
votes

I have this xml file, I want to extract all xelement having number value in it attibute using XPath

<XtraSerializer version="1.0" application="TabbedView">
  <property name="Items" iskey="true" value="5">
    <property name="Item1" isnull="true" iskey="true">
      <property name="Name">5d297655-eee4-4ab5-baa7-7d12964ac1ad</property>
      <property name="TypeName">Document</property>
    </property>
    <property name="Item3" isnull="true" iskey="true">
      <property name="Name">48575907</property>
      <property name="TypeName">DockingContainer</property>
    </property>
    <property name="Item4" isnull="true" iskey="true">
      <property name="Index">0</property>
      <property name="Name">63403262</property>
      <property name="TypeName">DockingContainer</property>
    </property>
  </property>
</XtraSerializer>

My result must be:

<property name="Name">48575907</property>
<property name="Name">63403262</property>

I use this syntax //property[text()=number] in the tester https://www.freeformatter.com/xpath-tester.html#ad-output

But it give me NO MATCH!

What is wrong with the syntax I used to achieve the goal?

1

1 Answers

0
votes

Try this XPATH that returns property node with integer value that not equal to 0

//property[number(text()) != 0]

if you want to fetch zero-value also:

//property[number(text()) != 0 or number(text()) = 0]