Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(newbee) Showing XMLDocument file in browser

Status
Not open for further replies.

karbon

Programmer
Dec 4, 2003
29
TR
Hi All
I have created XML File with XMLDocument in ASP.NET
than i want send or show this file in browser to visitors.
without saving it to disk. How can i do that?

i want to show (MyXML) in explorer. or post it to customers?


Dim dst As DataSet
dst = ReturnDatasetFromSql(db, "Select * from Customers")
Dim MyXML As XmlDocument
MyXML[/color red] = DataTableToXML(dst.Tables(0))


Private Function DataTableToXML(ByVal table As DataTable) As XmlDocument
Dim xml As New XmlDocument
xml.LoadXml("<tableData/>")
For Each dr As DataRow In table.Rows
Dim rowElem As XmlElement
rowElem = xml.CreateElement("row")
For Each col As DataColumn In table.Columns
Dim colElem As XmlElement
colElem = xml.CreateElement(col.ColumnName)
colElem.InnerText = dr(col).ToString()
rowElem.AppendChild(colElem)
Next
xml.DocumentElement.AppendChild(rowElem)
Next dr
Return xml
End Function

 
In what context are you creating the XML?

Jon

"I don't regret this, but I both rue and lament it.
 
Imports System.xml
I create the xml document in ASP.NET VB by connecting SQLServer2000.

The code above works fine.

I have no problem about creating the XML Document.
I load my data to MyXML...

Now i just want to open this XML in visitors browser...
or send it to visitor(Save as Page)....

thanks
 

i thougt it was easy question for ASP.NET developers...
:(
 
Where do you execute this code? In the page load event?

Why not just use MyXml.InnerXml?

You'll need to do a string replace of "<" with "&lt;" and ">" with "&gt;"

Jon

"I don't regret this, but I both rue and lament it.
 
i execute it in Command_click event.
i connect to SQL2000 and load data into XmlDocument
Dim MyXML As XmlDocument

Assume that i have xml in XML document like below.

<ORDERS>
<ORDER_DATE>8/3/2005</ORDER_DATE>
<ORDER_NUMBER>124233</ORDER_NUMBER>
</ORDERS>

i just want to send it to visitors. or show Save as Dialog Box to visitors...
*i dont want to save it to webserver as xxx.xml as file.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top