Nelviticus
Programmer
I'm trying to parse a document list which is in the form of an XMLNode (retrieved from Sharepoint). The code I have works but I'm sure I'm doing it in the wrong way so I wondered if someone could show me how it's supposed to be done.
The OuterXML looks a bit like this (I have stripped out most of the attributes):
My code is as follows - ndListItems is an XMLNode:
Is there a better way of doing it than this? I just want to build a list of the <z:row /> items within the <rs:data /> element. Ideally I just want the rows where the 'ows_DocIcon' attribute is "xlsx" but would be happy with just a cleaner way of getting all the rows.
Thanks
Nelviticus
The OuterXML looks a bit like this (I have stripped out most of the attributes):
Code:
<listitems xmlns:s="blah">
<rs:data ItemCount="6">
<z:row ows_DocIcon="xlsx"/>
<z:row ows_DocIcon="aspx"/>
</rs:data>
</listitems>
My code is as follows - ndListItems is an XMLNode:
Code:
if (ndListItems.ChildNodes.Count > 2) {
foreach (XmlNode thisNode in ndListItems) {
if (thisNode.NodeType == XmlNodeType.Element) {
foreach (XmlNode subNode in thisNode) {
if (subNode.NodeType == XmlNodeType.Element) {
// Do stuff with subNode
}
}
}
}
}
Is there a better way of doing it than this? I just want to build a list of the <z:row /> items within the <rs:data /> element. Ideally I just want the rows where the 'ows_DocIcon' attribute is "xlsx" but would be happy with just a cleaner way of getting all the rows.
Thanks
Nelviticus