Many people know that when querying a sharepoint list via the LisWebService.getListItems() method you will receive xml data back in the following format:
<listitems ...>
<rs:data ..../>
<z:row attribute1 attribute2 ..../>
<z:row attribute1 attribute2 ..../>
</rs:data>
</listitems>
If any list item contains invalid xml (such as hex character 0x11) an InvalidOperationException is thrown similar to:
System.InvalidOperationException: There is an error in XML document (Line, Pos). ---> System.Xml.XmlException: 'bad character', hexadecimal value 0x[something], is an invalid character........
I'm trying to come up with an automated process to find which list item is the problem. Since the I already know the format of a successful query result, I was hoping that the line number from the xml exception could help me determine this.
So if an exception was reported to be in line 4 in the sample xml above, that would indicate that the problem item was the second z:row.
This process works fine when I'm loading in an xml document from my local machine via xmlDoc.Load("fileName"); The local xml document contains exactly the xml format mentioned above with illegal characters placed as attribute values.
However, the line number is confusing when thrown from the getListItems method. I know that the <listitems> node returned from a successful query for this particular list is only 450 lines long (including the listitem nodes, the rs:data nodes, and all of the z:row nodes). However when the exception is thrown, the line number is 3000.
Apparently there is a difference between my understanding of the word "line" and the line number from the exception. Are there other nodes coming in to play that I am missing here? Are embedded "\n" characters in the xml contributing to this? Can anyone clear up this inconsistency?
Thanks
↧
ListService.getListItems - Xml Exception for invalid character - need clarification
↧