Using xpath to locate an element
Hi
I’m having a problem changing the text value of an element in an xml file using xpath.
My file structure looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns=" name="ProjectName">
<description></description>
<contact></contact>
<NVPairs name="Global Variables">
<NameValuePair>
<name>DirLedger</name>
<value>.</value>
</NameValuePair>
<NameValuePair>
<name>DirTrace</name>
<value>.</value>
</NameValuePair>
<NameValuePair>
<name>HawkEnabled</name>
<value>false</value>
</NameValuePair>
</NVPairs>
</application>
I want to be able to find “DirLedger”
I tried these Xpath’s:
/application/NVPairs/NameValuePair [./name = 'DirLedger'] (won’t work)
//*[local-name()=”application”]/NVPairs/NameValuePair [./name = 'DirLedger'] (should work)
I remove the string “xmlns=" name="ProjectName"” it works fine.
Can any one help me with this?
Thank you
Hi
I’m having a problem changing the text value of an element in an xml file using xpath.
My file structure looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns=" name="ProjectName">
<description></description>
<contact></contact>
<NVPairs name="Global Variables">
<NameValuePair>
<name>DirLedger</name>
<value>.</value>
</NameValuePair>
<NameValuePair>
<name>DirTrace</name>
<value>.</value>
</NameValuePair>
<NameValuePair>
<name>HawkEnabled</name>
<value>false</value>
</NameValuePair>
</NVPairs>
</application>
I want to be able to find “DirLedger”
I tried these Xpath’s:
/application/NVPairs/NameValuePair [./name = 'DirLedger'] (won’t work)
//*[local-name()=”application”]/NVPairs/NameValuePair [./name = 'DirLedger'] (should work)
I remove the string “xmlns=" name="ProjectName"” it works fine.
Can any one help me with this?
Thank you