What's new
Visual Studio.Net Help Community

A community to get Microsoft Visual Studio.Net programming help.

Visual Studio.Net Help Community is a community for .Net programmers to interact with people who want to learn to program using the Microsoft Visual Studio.Net languages or who program using the Microsoft .Net languages and want to share their .Net knowledge.

Visual Studio.Net Help Community is a free programmer help site so why not join the community today? Once you are a member you get access to all our .Net programming discussions.

XElement and XDocument in LINQ raise exception when an attribute value contains a special character

EDN Admin

Staff member
Aug 7, 2010
In the Machine
The below code is throwing xmlException -var appContexts = from suitFile in GetValidSuitFiles(directoryToTraverse)
let contextNode = XElement.Load(suitFile)
where IsAppContextNode(contextNode) &&
contextNode.HasElements &&
select new AppContextInfo(contextNode);

Exception is coming from XElement.Load(fileName). The file contains a special character as part of the value of an attribute not in the attribute name or the tag name.
The exception obtained is -
"<special character is here. I copied it but could not paste it.>, hexadecimal value 0x03, is an invalid character. Line 287, position 103.".
We need to be able to load the file with the special character and we also need to use LINQ as we need to process 100s of files.
Any help is appreciated.

View the full article

Top Bottom