I’m new to Xpath and having troubles extracting the values I want here. This is an excerpt of my XML file -
<?xml version="1.0"?>
<Response command="view" app="ci" version="4.10.0 2-1 5467">
<App-Connection port="1234" userID="fred" server="slate.com"></App-Connection>
<WorkItems selectionType="IssueIDToIssueSelection">
<WorkItem id="4321" displayId="4321" modelType="im.Issue">
<Field name="Type">
<Item id="Gravel" displayId="Gravel" modelType="im.Type">
</Item>
</Field>
<Field name="ID">
<Value dataType="int">4321</Value>
</Field>
<Field name="Summary">
<Value dataType="string">Bronty Burgers</Value>
</Field>
<Field name="State">
<Item id="Active" displayId="Active" modelType="im.State">
</Item>
</Field>
<Field name="Rubble">
<Value dataType="string">Hunger</Value>
</Field>
….
I can obtain the “State” value I’m after -
PS D:\> $xml.SelectNodes("//Field[@name='State']/Item/@id")
#text
-----
Active
However for the “Rubble” value, I’m getting the datatype returned as well as the value. Any idea how I can just get the value returned?
PS D:\> $xml.SelectNodes("//Field[@name='Rubble']/Value")
dataType #text
-------- -----
string Hunger
Thanks…
<?xml version="1.0"?>
<Response command="view" app="ci" version="4.10.0 2-1 5467">
<App-Connection port="1234" userID="fred" server="slate.com"></App-Connection>
<WorkItems selectionType="IssueIDToIssueSelection">
<WorkItem id="4321" displayId="4321" modelType="im.Issue">
<Field name="Type">
<Item id="Gravel" displayId="Gravel" modelType="im.Type">
</Item>
</Field>
<Field name="ID">
<Value dataType="int">4321</Value>
</Field>
<Field name="Summary">
<Value dataType="string">Bronty Burgers</Value>
</Field>
<Field name="State">
<Item id="Active" displayId="Active" modelType="im.State">
</Item>
</Field>
<Field name="Rubble">
<Value dataType="string">Hunger</Value>
</Field>
….
I can obtain the “State” value I’m after -
PS D:\> $xml.SelectNodes("//Field[@name='State']/Item/@id")
#text
-----
Active
However for the “Rubble” value, I’m getting the datatype returned as well as the value. Any idea how I can just get the value returned?
PS D:\> $xml.SelectNodes("//Field[@name='Rubble']/Value")
dataType #text
-------- -----
string Hunger
Thanks…