• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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']]
 
Do Re Mi Fa So La Tiny Ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic