开发者

XML structure question

I have a basic XML object that I'm working with. I can't figure out how to access the parts of it.

 <FacetsData>
  <Collection name="CDDLALL" type="Group">
   <SubCollection name="CDDLALL" type="Row">
    <Column name="DPDP_ID">D0230< /Column>
    <Column name="Count">9< /Column>
   </SubCollection>
   <SubCollection name="CDDLALL" type="Row">
    <Column name="DPDP_ID">D1110< /Column>
    <Column name="Count">9< /Column>
   </SubCollection>
  </Collection>
 </FacetsData>

What I need to do is check each DPDP_ID and if its value is D0230 then I leave the Count alone, all else I change the Count to 1.

What I have so far:

node = doc.DocumentElement;
nodeList = node.SelectNodes("/FacetsData/Collection/SubCollection");
for (int x = 0; x < nodeList.Count; x++) {
 if (nodeList[x].HasChildNodes) {
  for (int 开发者_JAVA技巧i = 0; i < nodeList[x].ChildNodes.Count; i++) {
   //This part I can't figure out how to get the name="" part of the xml
   //MessageBox.Show(oNodeList[x].ChildNodes[i].InnerText); get the "D0230","1"
   //part but not the "DPDP_ID","Count" part.
  }
 }
}


Each node has an Attributes collection. You can do

nodeList[x].ChildNodes[i].Attributes["name"].value 

to get the value.


You access it through oNodeList[x].ChildNodes[i].Attributes["name"].

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜