के माध्यम से विशेषता नोड का मूल्य निकालें XPath के माध्यम से एक विशेषता नोड का मान कैसे निकाला जा सकता है?XPath
एक नमूना एक्सएमएल फ़ाइल है:
<parents name='Parents'>
<Parent id='1' name='Parent_1'>
<Children name='Children'>
<child name='Child_2' id='2'>child2_Parent_1</child>
<child name='Child_4' id='4'>child4_Parent_1</child>
<child name='Child_1' id='3'>child1_Parent_1</child>
<child name='Child_3' id='1'>child3_Parent_1</child>
</Children>
</Parent>
<Parent id='2' name='Parent_2'>
<Children name='Children'>
<child name='Child_1' id='8'>child1_parent2</child>
<child name='Child_2' id='7'>child2_parent2</child>
<child name='Child_4' id='6'>child4_parent2</child>
<child name='Child_3' id='5'>child3_parent2</child>
</Children>
</Parent>
</parents>
अब तक मैं इस XPath स्ट्रिंग है:
//Parent[@id='1']/Children/child[@name]
यह केवल child
तत्वों देता है, लेकिन मैं name
विशेषता के मान करना चाहते हैं ।
मेरी नमूना एक्सएमएल फ़ाइल के लिए, यहाँ मैं अपनी पसंद का उत्पादन होने का है:
Child_2
Child_4
Child_1
Child_3
संभावित डुप्लिकेट [XPath का उपयोग करके विशेषता प्राप्त करना] (http: // stackoverflow।कॉम/प्रश्न/4531995/हो रही-विशेषता-उपयोग-xpath) – tripleee