473,378 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

WriteXML encoding strings ! Please help

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 "&lt;" 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>&lt;row tID="1" tNo="11"
tLeft="123" tTop="432"/&gt;</XML_F52E2B61-18A1-11d1-B105-00805F49916B>
</Tables>

Please assist urgent!

Thanks
sorCrer
Nov 12 '05 #1
2 3715
sorCrer wrote:
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 "&lt;" This
means that the script that I am using can't recognise the first node.

Why is this behaviour implemented?
In XML < characters in text and attribute values must be escaped.
I basically end with this

<Tables>
<XML_F52E2B61-18A1-11d1-B105-00805F49916B>&lt;row tID="1" tNo="11"
tLeft="123" tTop="432"/&gt;</XML_F52E2B61-18A1-11d1-B105-00805F49916B>
</Tables>


What's you start with?
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).

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
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

"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

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Pekka Niiranen | last post by:
Hi, Probing my system from Python 2.3.4 gives >>> import locale, sys >>> locale.getdefaultlocale() ('fi_FI', 'cp1252') >>> locale.getpreferredencoding() 'cp1252' >>>...
0
by: johkar | last post by:
My XML and XSL is below. Also below is a textual representation of what I want to get out of the XML with XSL. For each Extension node in XML, I am only concerned with those nodes with...
1
by: news.hunterlink.net.au | last post by:
(* note the escaped ampersand and the character reference have extra spaces to avoid being converted when viewed) I have a job that requires the following <ThisElement>Here is some text & a m...
7
by: Alan Bashy | last post by:
Please, guys, In need help with this. It is due in the next week. Please, help me to implement the functions in this programm especially the first three constructor. I need them guys. Please, help...
22
by: stoppal | last post by:
need to extract all text between the following strings, but not include the strings. "<!-- #BeginEditable "Title name" -->" "<p align="center">#### </p>" I am using preg_match(????, $s,...
2
by: Michael Barrido | last post by:
Greetings! I have a project that needs to access a web service. My problem is this web service is provided via CGI. I cannot do a "Web Reference" to it to add in my dotnet project. I'm planning to...
4
by: Jcs_5920 | last post by:
Hello All, I was reading some of the posts trying to learn about date coding schemes used in old DOS programs with no luck, so I though I'd ask the group for help. These are the HEX values and...
2
by: varusnyc | last post by:
Hello, I just started learning strings and dont even know how to properly execute simple part of the program that splits phrase of two words with one space in between into 2 separate strings. I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.