473,394 Members | 1,828 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,394 software developers and data experts.

Dataset WriteXml Problem

Could somebody please point out my error in the following code. The
dataset is returned by a stored procedure containing FOR XML AUTO,
ELEMENTS, but the XML Document that is created contains < and >
instead of < and >. I have tried everything that I can think of
without any success, which probably means that I am missing something
obvious.

Dim dsERF As New DataSet
dsERF = clsList.TableData

Dim filename As String = "C:\Inetpub\wwwroot\ISSPost
\NewXmlDoc.xml"
Dim myFileStream As New System.IO.FileStream _
(filename, System.IO.FileMode.Create)
Dim myXmlWriter As New System.Xml.XmlTextWriter _
(myFileStream, System.Text.Encoding.Unicode)
myXmlWriter.Formatting = System.Xml.Formatting.Indented
dsERF.WriteXml(myXmlWriter, XmlWriteMode.IgnoreSchema)
myXmlWriter.Close()

The generated XML appears as follows.

<NewDataSet>
<Table>
<XML_F52E2B61-18A1-11d1-B105-00805F49916B>&lt;row Message="No
records were found. Please change at least one dropdown selection."/
&gt;</XML_F52E2B61-18A1-11d1-B105-00805F49916B>
</Table>
</NewDataSet>

Jun 13 '07 #1
4 4308
cl********@alltel.net wrote:
Could somebody please point out my error in the following code. The
dataset is returned by a stored procedure containing FOR XML AUTO,
ELEMENTS, but the XML Document that is created contains &lt; and &gt;
instead of < and >. I have tried everything that I can think of
without any success, which probably means that I am missing something
obvious.
I don't think the problem is with the .NET code. Have you controlled the
output of the stored procedure direcly with SQL Server Management Studio?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 13 '07 #2
On Jun 13, 8:22 am, Martin Honnen <mahotr...@yahoo.dewrote:
clockem...@alltel.net wrote:
Could somebody please point out my error in the following code. The
dataset is returned by a stored procedure containing FOR XML AUTO,
ELEMENTS, but the XML Document that is created contains &lt; and &gt;
instead of < and >. I have tried everything that I can think of
without any success, which probably means that I am missing something
obvious.

I don't think the problem is with the .NET code. Have you controlled the
output of the stored procedure direcly with SQL Server Management Studio?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
The returned XML data, as it appears in SQL Server Management Studio,
is as follows.

<CC>
<Message>No records were found. Please change at least one dropdown
selection.</Message>
</CC>

The &lt; and &gt; mean that I cannot then use the getElementsByTagName
method in JavaScript. My reason for writing code like this (and
perhaps you know of a far easier solution) is that I have to replace
all calls to SQL XML Templates that my site previously used, as the
website and database are being moved to separate servers, and the
website server does not have SQL on it.

Many thanks.

Jun 13 '07 #3
cl********@alltel.net wrote:
The returned XML data, as it appears in SQL Server Management Studio,
is as follows.

<CC>
<Message>No records were found. Please change at least one dropdown
selection.</Message>
</CC>
Why are you using a DataSet? If you simply want to write out the XML
returned by SQL server then you could use ExecuteXmlReader() to get an
XmlReader and write that out with an XmlWriter and the WriteNode method.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 13 '07 #4
On Jun 13, 10:35 am, Martin Honnen <mahotr...@yahoo.dewrote:
clockem...@alltel.net wrote:
The returned XML data, as it appears in SQL Server Management Studio,
is as follows.
<CC>
<Message>No records were found. Please change at least one dropdown
selection.</Message>
</CC>

Why are you using a DataSet? If you simply want to write out the XML
returned by SQL server then you could use ExecuteXmlReader() to get an
XmlReader and write that out with an XmlWriter and the WriteNode method.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Thanks Martin for your help. I was using a dataset as all of my server-
side code uses the same class to return data, none of which is XML, so
I was minimizing my code as I attempted to find a solution. All of my
XML data had previously been returned by XMLHttpRequests in
JavaScript. Eventually I found that removing the FOR XML AUTO from the
stored procedure solved the problem. I still hope to find a solution
that will enable me to continue to use JavaScript to return the data.

Jun 13 '07 #5

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

Similar topics

4
by: Simon | last post by:
Hi all, I have a process, where I take a dataset from an SQL call, and need to write an XML file from that dataset. The data set can contain 10's of tables, each with 100's of rows, and I have...
1
by: Wil | last post by:
I'm very new to developing in .NET and even newer to XML. The past few days have been pretty frustrating for me because I'm trying to perform a transform on data in a dataset and it's not working....
2
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as...
1
by: Dave | last post by:
Hi all, I've seen that many people have had this exact same problem in the past, but no-one seems to post the answer when (if) they solve it... so here we go again. If I create a strongly...
3
by: Joe98765 | last post by:
I have data coming from SQL Server and need to write out some XML. I have a schema(xsd) for this XML file. Right now I am bringing in the DataSet and writing out the elements and attributes myself...
1
by: RS | last post by:
I have a dataset that was created from a XSD schema. I populate it with data and use WriteXml method to create XML document. Problem is XML tags come out in the order that is different from the...
3
by: Serdar C | last post by:
hello there, i am writing a program that generates random numbers and shows the numbers on a (x,y) chart.. i decided to use crystal reports to draw the chart and a dataset.readxml to read data.....
4
by: Wes | last post by:
Hello, I have an application using an xml dataset to store app and user settings. The problem I am having is related to writexml. I have a save button on my application that updates the dataset...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
4
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got a DataSet that I save as XML using the DataSet DataTable's WriteXml method. If I say XmlWriteMode.IgnoreSchema, it shows up great in Excel, but I can not reopen the file in my...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.