I"m pulling down data from GetListItems using SP Web Services. I want as much data as possible since I'm storing that off into a local XML document. I'm also trying to create a TSV from the data.
The returned XML is something like this:
<rs:data ItemCount="896" xmlns:rs="urn:schemas-microsoft-com:rowset">
<z:row ows_A="1" ows_B="2" xmlns:z="#RowsetSchema" />
There's actually closer to 60+ attributes per row, and the problem is the returned attributes per "row" aren't consistent (e.g. some have 60, some have 67, some have 59, etc).
If I explicitly ask for the attributes by name, it's not a big deal:
foreach (System.Xml.XmlNode listItem in nodeListItems)
{
if (listItem.Name == "rs:data")
{
for (int i = 0; i < listItem.ChildNodes.Count; i++)
{
if (listItem.ChildNodes[i].Name == "z:row")
{
wtSr.Append(listItem.ChildNodes[i].Attributes["ows_Title"].Value);
wtSr.Append("\t");
etc, etc.
I tried parsing through all the attributes using something like
for (int k = 0; k < listItem.ChildNodes[i].Attributes.Count; k++)
{
tmpWtCol = listItem.ChildNodes[i].Attributes[k].Name.ToString().Replace("ows_", string.Empty).Replace("_", string.Empty);
wtSr.Append(tmpWtCol + "\t");
wtDidHeaders = true;
}
to get the possible attributes, but I realized it would only pick up the first row, which may or may not have the maximum attributes possible. I thought about parsing through the entire thing. Though it's unlikely, I also have no real way of knowing if the "biggest count" row contains every combination.
Is there a more elegant solution to with "null" (missing) attributes and determining all the attributes to create an acceptable "column list"?