I have an xml document that looks like this:
<?xml version="1.0" encoding="utf-8"standalone="yes"?>
<WorkItem TimeZone="Mountain Standard" Offset="-07:00:00">
<RevisionFields>
<Field ReferenceName="OriginalTestEstimate" Name="Estimated Test" Type="Double">
<Value>5</Value>
</Field>
<Field ReferenceName="RemainingDevWork" Name="Remaining Dev" Type="Double">
<Value>9</Value>
</Field>
<Field ReferenceName="RemainingTestWork" Name="Remaining Test" Type="Double">
<Value>5</Value>
</Field>
...
A TFS service that I am calling gives it to me as an XmlDocument
object. I am trying to access the Value
parts of the fields. I can use workItem["WorkItem"]["RevisionFields"]
to get to the array of all the fields, but when I try to get at a specific field using this notation I get stuck.
Since the "Name" is set I tried using that (ie workItem["WorkItem"]["RevisionFields"]["Remaining Test"]
but that just returns null.
What do I need to do so I can get directly at the values in the fields? (I woul开发者_如何学God prefer to not have to iterate all of the fields.)
You could use XPath to retrieve the node:
/WorkItem/RevisionFields/Field[@Name='Remaining Test']/Value
Look at the SelectSingleNode()
method (and the SelectNodes()
method).
精彩评论