Hi there,
I`m new to Xpath and got a problem. I want all nodes under a specific parent-node! I tried it with this query, but only get an empty result! :(
var ISDN_confs = from x in xdoc.XPathSelectedElements("//member[name='participantOne']//member[name='name']")
select x;
Sample XML:
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>calls</name>
<value>
<array>
<data>
<value>
<struct>
<member>
<name>uniqueId</name>
<value>
<int>6</int>
</value>
</member>
<member>
<name>participantOne</name>
<value>
<struct>
<member>
<name>uniqueId</name>
<value>
<int>1609</int>
</value>
</member>
<member>
<name>protocol</name>
<value>
<string>h323</string>
</value>
</member>
<member>
<name>incoming</name>
<value>
<boolean>1</boolean>
</value>
</member>
<member>
<name>progress</name>
<value>
<string>connected</string>
</value>
</member>
<member>
<name>fecc</name>
<value>
<boolean>1</boolean>
</value>
</member>
<member>
<name>videoCodec</name>
<value>
<string>h264</string>
</value>
</member>
<member>
<name>audioCodec</name>
<value>
<string>g722</string>
</value>
</member>
<member>
<name>autoAttendant</name>
<value>
<boolean>0</boolean>
</value>
</member>
<member>
<name>name</name>
<value>
<string>Test Endpoints</string>
</value>
</member>
<member>
<name>number</name>
<value>
<string>12345</string>
</value>
</member>
<member>
<name>ipAddress</name>
<value>
<string>192.168.2.155</string>
</value>
</member>
<member>
<name>callIdentifier</name>
<value>
<base64>CCCCVVVVVDDDDD</base64>
</value>
</member>
</struct>
</value>
</member>
<member>
<name>participantTwo</name>
<value>
<struct>
<member>
<name>name</name>
<value>
<string/>
</value>
</member>
<member>
<name>number</name>
<value>
<string>123456</string>
</value>
</member>
<member>
<name>channels</name>
<value>
<array>
<data>
<value>
<int>1</int>
</value>
<value>
<int>2</int>
</value>
</data>
</array>
</value>
</member>
</struct>
</value>
</member>
</struct>
</value>
The desired output should be a limited variation of the actual output. So i dont want all the name-members, but the name-members in the two structures without channels-members.
I hope its clear what I want! :)
Sample Output:
<member>
<name>name</name>
<value>
<string>Test Endpoints</string>
</value>
</member>
At the moment, with the above query, I get all name-members, but thats not what I want, like I said in the comments below!
UPDATE--- I tried to get all name-member which have channels-members with this query
var parts = from c in xdoc.XPathSelectElements("//member[name='name']")
where c.Element("name").Value == "channels" && c.Element("name").HasElements
select c;
but only get an empty result!