|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
WriteXML encoding strings ! Please helpGoing crazy with this problem! I fill a dataset in asp.net with a 'FOR XML AUTO' query and Output it back to the browser. > DS.WriteXml(Response.OutputStream, XmlWriteMode.IgnoreSchema) No matter what I do I get the first nodes "<" encoded as "<" Thismeans that the script that I am using can't recognise the first node. I would replace the characters but then the output is no longer recognised as XML. Why is this behaviour implemented? I basically end with this <Tables> <XML_F52E2B61-18A1-11d1-B105-00805F49916B><row tID="1" tNo="11" tLeft="123" tTop="432"/></XML_F52E2B61-18A1-11d1-B105-00805F49916B> </Tables> Please assist urgent! Thanks sorCrer sorCrer wrote:
> I fill a dataset in asp.net with a 'FOR XML AUTO' query and Output it In XML < characters in text and attribute values must be escaped.> back to the browser. > > >>DS.WriteXml(Response.OutputStream, XmlWriteMode.IgnoreSchema) > > > No matter what I do I get the first nodes "<" encoded as "<" This > means that the script that I am using can't recognise the first node. > Why is this behaviour implemented? > I basically end with this What's you start with?> > <Tables> > <XML_F52E2B61-18A1-11d1-B105-00805F49916B><row tID="1" tNo="11" > tLeft="123" tTop="432"/></XML_F52E2B61-18A1-11d1-B105-00805F49916B> > </Tables> Looks like you start with embedded XML as a character data? That's the problem - you've got it as text and so DataSet writes it as text, escaping < and &. So the solution is either to change the way you store it or disable escaping (e.g. using XSLT or custom XmlWriter). Hi SorCrer
How are you getting the XML back from your query? You need to use the ExecuteXmlReader method on your SqlCommand object... This works OK for me... Dim conn As New System.Data.SqlClient.SqlConnection("connString") Dim comm As New System.Data.SqlClient.SqlCommand("SELECT * FROM Table FOR XML AUTO", conn) conn.Open() Dim r As System.Xml.XmlReader = comm.ExecuteXmlReader() Dim ds As New DataSet ds.ReadXml(r) r.close() conn.Close() MessageBox.Show(ds.GetXml()) Let me know if you need more help Nigel Armstrong Show quote "sorCrer" wrote: > Hi Guru's, > > Going crazy with this problem! > > I fill a dataset in asp.net with a 'FOR XML AUTO' query and Output it > back to the browser. > > > DS.WriteXml(Response.OutputStream, XmlWriteMode.IgnoreSchema) > > No matter what I do I get the first nodes "<" encoded as "<" This > means that the script that I am using can't recognise the first node. > I would replace the characters but then the output is no longer > recognised as XML. > > Why is this behaviour implemented? I basically end with this > > <Tables> > <XML_F52E2B61-18A1-11d1-B105-00805F49916B><row tID="1" tNo="11" > tLeft="123" tTop="432"/></XML_F52E2B61-18A1-11d1-B105-00805F49916B> > </Tables> > > Please assist urgent! > > Thanks > sorCrer > |
|||||||||||||||||||||||