Click here to Skip to main content
15,846,038 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

I reading an XML.

I am getting exception, when I use DataSet.ReadXml(xmlfile).

Please help
Vedat Ozan Oner 12-Feb-14 5:31am    
I think you use 'xmlfile' as path to your xml. check that string. it is not a real path.
srmohanr 12-Feb-14 5:33am    
Actually I getting this xml from server, saving it as a string, passing it to DataSet

The "Illegal characters" exception means that the file path string you are passing to ReadXml is wrong: it is not a valid path. It may contain '?', or ':' in the wrong place, or '*' for example.

You need to look at the value, check what it is, and work out where the illegal character(s) are coming from.
Share this answer
srmohanr 12-Feb-14 5:51am    
As I noticed no such characters in my XML string.
Any method is available to check for illegal characters.?
OriginalGriff 12-Feb-14 6:16am    
It's not the "xml string" that's the problem: it's the path to the file containing the XML that's the problem.

DataSet.ReadXML uses the string you pass to it as a file name, not as the actual XML to process:

If you want to pass "raw" XML, then you need to wrap it in a stream, and pass that instead:

ds.ReadXml(new StringReader(strXml))
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900