By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,667 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,667 IT Pros & Developers. It's quick & easy.

Use ReadXML of XSD works with XMLReader but not with Stream-any id

P: n/a

sXML - has XML string
//This dies on ReadXML - something about invalid character
MemoryStream stream = new MemoryStream(sXML.Length);
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter
binaryFormatter = new
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter();
binaryFormatter.Serialize(stream, sXML);
stream.Position = 0;

xs.ReadXml(stream);

//This works just fine
System.Xml.XmlReader rdr = System.Xml.XmlReader.Create(new
System.IO.StringReader(sXML));

xs.ReadXml(rdr);

curious what is different???

Thanks
Jul 11 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
sippyuconn <si********@newsgroup.nospamwrote:
sXML - has XML string
//This dies on ReadXML - something about invalid character
MemoryStream stream = new MemoryStream(sXML.Length);
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter
binaryFormatter = new
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter();
binaryFormatter.Serialize(stream, sXML);
stream.Position = 0;

xs.ReadXml(stream);
You're uing a binary formatter on the string, which is likely to add
extra stuff to indicate that it *is* a string.

If you just use Encoding.UTF8.GetBytes(sXML) (or whatever encoding the
XML is in) then it should be okay.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon_skeet
C# in Depth: http://csharpindepth.com
Jul 11 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.