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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic XML question

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
US
Hi all,
In sql server 2005, I'm just getting my feet wet with the FOR XML clause.
When I use For Xml Auto, what it seems to do is create a bunch of elements using the table name as the element name (an element for each row returned), and then instead of sub-child elements for each field, it instead makes each field an attribute of the only element level.

So my question is: would it not be more 'typical' to have the row as an element, then each field as a child element to the row?

The end game here is that I just want to simplify outputting data to the web, via asp pages. I've been able to use the adodb.stream object and can get the raw xml output, and now I want to use an xsl sheet with it, and it seems more natural to have each field as a child element. I think I can make it work as-is, but I'm just wondering if there's ways to tweak the For XML clause to adjust how it outputs the stream.
Thanks,
--Jim
 
sqlprograms,
Thank you, but that article is more geared towards the xml data type.

However, I continued searching and found an article that does explain exactly what I was looking for...so if anyone else stumbles upon this and wants to know:

In short, it's the Elements keyword that does what I'd wanted,
--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top