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
Joined
Aug 7, 2010
Location
In the Machine
#1
Hi,
The below code is throwing xmlException -var appContexts = from suitFile in GetValidSuitFiles(directoryToTraverse)
let contextNode = XElement.Load(suitFile)
where IsAppContextNode(contextNode) &&
contextNode.HasElements &&
IsAppContextCodeGenerated(contextNode)
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.
Regards,
Rajesh

View the full article
 

Top Bottom