Click here to Skip to main content
14,837,944 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I reading an XML.
HTML
<User>
  <Event>
    <NAME>Event1</NAME>
    <DEST_NT_DOMAIN>MACHINE</DEST_NT_DOMAIN>
    <SRC_USER_NAME>UserBBBB</SRC_USER_NAME>
    <DEST_USER_NAME>None</DEST_USER_NAME>
    <DEST_USER_ID>{S-1-5-21-583907252-920026266-1060284298-513}</DEST_USER_ID>
    <CAT_BEHAVIOR>/Authentication/Add</CAT_BEHAVIOR>
  </Event>
</User>


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

Please help
Posted
Comments
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.
   
Comments
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:
http://msdn.microsoft.com/en-us/library/360dye2a(v=vs.110).aspx

If you want to pass "raw" XML, then you need to wrap it in a stream, and pass that instead:
http://msdn.microsoft.com/en-us/library/55hehd8c(v=vs.110).aspx
Use,

ds.ReadXml(new StringReader(strXml))
   

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