I try to create a dataset with Reporting Services from a SharePoint list (inside the root web).
When I want to build the query for the dataset I get the following error:
===================================
'', hexadecimal value 0x0B, is an invalid character. Line 1, position 9605. (System.Xml)
------------------------------
Program Location:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String[] args)
at System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Int32 pos, Char invChar)
at System.Xml.XmlTextReaderImpl.ParseNumericCharRefInline(Int32 startPos, Boolean expand, BufferBuilder internalSubsetBuilder, Int32& charCount, EntityType& entityType)
at System.Xml.XmlTextReaderImpl.ParseNumericCharRef(Boolean expand, BufferBuilder internalSubsetBuilder, EntityType& entityType)
at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos)
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.ReadCurrentNode(XmlDocument doc, XmlReader reader)
at System.Xml.XmlDocument.ReadNode(XmlReader reader)
at System.Xml.Serialization.XmlSerializationReader.ReadXmlNode(Boolean wrapped)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSPListService.Read53_GetListCollectionResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer102.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
What I learned is that some item(s) in some list and some field of the root web must have an invalid character. Not the same as the invalid characters for file names but invalid for the XmlDeserialization that is being used here (all below 0x20).
The character I know try to find an remove is "0x0B" (vertical tab). Does someone know how I can search for this character with C#.
Here's what I've tried so far:
static void Main(string[] args)
{
if (args != null && args.Length > 0)
{
string site = args[0];
int invalidChar = 0x0B;
using (SPWeb web = new Microsoft.SharePoint.SPSite(site).OpenWeb())
{
foreach (SPList list in web.Lists)
{
Console.WriteLine(string.Format("Processing list: {0}", list.Title));
try
{
foreach (SPField field in list.Fields)
{
if (!field.Hidden &&
field.GetType() == typeof(SPFieldMultiLineText))
{
//Console.WriteLine(string.Format("- MLT-Field found: {0}", field.InternalName));
foreach (SPListItem item in list.Items)
{
try
{
if (item.Fields.ContainsField(field.InternalName) &&
item[field.Id] != null &&
item[field.Id].ToString().Contains(invalidChar.ToString()))
{
Console.WriteLine(string.Format("- Invalid character found. Item: {0}, Field: {1}", item.ID, field.InternalName));
}
}
catch (Exception ex)
{
Console.WriteLine(string.Format("- Error on checking item: {0}. Error: {1}", item.ID, ex.Message));
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(string.Format("- Error on checking fields of list. Error: {0}", ex.Message));
}
}
}
}
}
But I was unsuccessful in finding it (to many false results). I believe that this "conversion" doesn't get me the real "0x0B" character as it is stored in the field values.
Does anyone have an idea to solve this?
char.ConvertFromUtf32(160)
where 160 is the base10 value of the char. – Philippe Lavoie Jul 5 '12 at 16:29