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

XmlReader and XML Web Control

Hi

I am trying to use the XML Web Control and the XmlReade
but when I try and load the xmlReader into the XmlDocument is gives me this erro

Error: This document already has a DocumentElement node
It fails at: doc.Load(myXmlReader

Is there something I am missing

Here is my code

Dim myCommand As SqlCommand = New SqlCommand("Select proddesc from invli where custid = '1STRFA' for xml auto", myConnection
myConnection.Open(

Dim myXmlReader As System.Xml.XmlReader = myCommand.ExecuteXmlReader(

Dim doc As XmlDocument = New XmlDocumen
doc.Load(myXmlReader

Dim trans As XslTransform = New XslTransfor
trans.Load(Server.MapPath("ProductTable.xsl")

Xml1.Document = do
Xml1.Transform = tran

Thank
Jeff
Nov 12 '05 #1
1 1722
Jeff wrote:
I am trying to use the XML Web Control and the XmlReader
but when I try and load the xmlReader into the XmlDocument is gives me this error

Error: This document already has a DocumentElement node.
It fails at: doc.Load(myXmlReader) Dim myXmlReader As System.Xml.XmlReader = myCommand.ExecuteXmlReader()


Most likely, this command returns XML with more than one root element,
such as
<Customers>
....
</Customers>
<Customers>
....
</Customers>

Such XML fragment cannot be loaded into XmlDocument.
You could use SqlXmlCommand instead of SqlCommand - former allows to
generate single rooted result (via RootTag property).
--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #2

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

Similar topics

5
by: xmlguy | last post by:
I believe this should be pretty elementary, but for some reason I cannot seem to think of how to write the an XML file from an incoming XML file. Basically this is what I do: Input: ...
2
by: xmlguy | last post by:
Cant seem to solve this problem I need to be able to re-use XmlReader and XPathDocument for an XSLT Transform. Basically I have defined following interfaces: Class Render (Common and...
2
by: xmlguy | last post by:
This is part of the application that reads XML from file (that has UTF-8) into an XmlTextReader XmlTextReader myXmlReader = new XmlTextReader(args); It then instantiates an object/class...
0
by: Jeff | last post by:
Hi, I am trying to use the XML Web Control and the XmlReader but when I try and load the xmlReader into the XmlDocument is gives me this error Error: This document already has a...
1
by: Angus Lepper | last post by:
I'm writing a stock ticker for a stock market simulation, and can load the data into the xmlreader in the first place, but can't figure out how to refresh/update the data in it. Any ideas? Code:...
0
by: Jen | last post by:
My main question: "How can I get a TextReader or Stream object from an existing XmlReader?". Read on for more: I have an existing XmlReader. Let's call it reader1. I'm creating another reader,...
6
by: Rob Meade | last post by:
Hi all, I'm having a few difficulties with the above, ie I cant find any good examples anywhere of how to do what I want to do! I have an xml file on my desktop which I want to read in. ...
5
by: heday60 | last post by:
I've got this application that watches a directory for XML's and then parses them into a DB. It then moves them based on if the XML was succesful or a bad XML... foreach(FileInfo file in...
0
by: gpet44 | last post by:
Hi, I have a problem receiving XML over a NetworkStream in C# .Net 2.0/3.0. I'm creating an XMLReader from the stream. I get the following exception when the XmlReaderreads from the stream as...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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.