Solved

sqlserver query to output xml into asp.net page

Posted on 2013-01-25
2
323 Views
Last Modified: 2013-01-25
Hi!

i Have simple data connection like this

Dim GetDataQry As String = "SELECT * from facilities where ItemID=@ItemId FOR XML PATH"
            Dim cmd As New SqlClient.SqlCommand(GetDataQry, conn)

with a SqlDataReader.

but it outputs only text. not xml as the query requests.
how do i get it to output xml into a asp.net page.
0
Comment
Question by:jamppi
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 305 total points
ID: 38820613
If you're writing this out to the page it could be that the browser is hiding the xml tags as unknown html tags, in that case you could try something like:
Response.Write yourxmlstringvar.Replace("<", "&lt;")

Open in new window

0
 

Author Closing Comment

by:jamppi
ID: 38820809
you got me on right track..  i had to change the document properties to
Response.ContentType = "text/xml"

then i got it right!

/J
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question