• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

XPath for atrib. name and value of node

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
i have specific problem with select from xml data via xpath. Here is the chunk of my xml file:
<zwk_export>
<record>
<field name="DEPOT_NR">1</field>
<field name="VALUE">463.18</field>
<field name="ART">1</field>
</record>
<record>
<field name="DEPOT_NR">1</field>
<field name="VALUE">5350.00</field>
<field name="ART">2</field>
</record>
...
<zwk_export>

Now i need to select all nodes "record" that has child "field" (note: all children are named "field") with attribute named "name" and value of that attrib. "ART" and value of the child node must be "1".
I tried these :
record[field/@name='ART' and (field/@name='ART') = '1']
record[field/@name = 'ART' and field/. = '1']

but these selected all nodes "field" that has child node "field" with attribute "name" and value of that attribute "ART" and has child "field" with value "1" (e.g. with child "DEPOT_NR" with value "1")but it is not able to select only "record" with such child:
<field name="ART">1</field>

The main problem is it mixes child <field name="ART">1</field>
and <field name="DEPOT_NR">1</field> but i do need identify positively "records" only with child <field name="ART">1</field>.

Can anyone help me?
 
Pavol Sestak
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If someone is interested here is the solution:
record[field[@name='ART'][.='1']]
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic