Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Programming
»
XML
»
Need to select all elements of an XML...
17 posts, Page 2 of 2
««
1
2
Need to select all elements of an XML document from an XML data type column
Rate Topic
Display Mode
Topic Options
Author
Message
davidsalazar01
davidsalazar01
Posted Tuesday, September 07, 2010 4:19 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 3:49 PM
Points: 170,
Visits: 332
Hi John,
I believe the output is fine from what I can tell as long as I can select all the elements from all the XML docs. Let me know if this will work based on the sample XML docs I've attached herein. In the sample docs I have selected the 1st row in the AmendBarsetFlightHistory table and displayed the XML document data that were in the columns (XMLBeforeAction and XMLAfterAction) as a reference of what I would like to select from this table. Let me know if this helps.
Thanks!
David
Post Attachments
XMLBeforeAction column - 1st record.docx
(
23 views,
19.40 KB
)
XMLAfterAction column - 1st record.docx
(
5 views,
19.34 KB
)
Post #981968
LutzM
LutzM
Posted Tuesday, September 07, 2010 4:43 PM
SSCertifiable
Group: General Forum Members
Last Login: Wednesday, April 24, 2013 3:17 PM
Points: 6,731,
Visits: 12,131
@John:
Since David addressing his issues implicit to your attention ignoring other posts, I leave this thread in your hands.
Lutz
A pessimist is an optimist with experience.
How to get fast answers to your question
How to post performance related questions
Links for
Tally Table
,
Cross Tabs
and
Dynamic Cross Tabs
,
Delimited Split Function
Post #981976
davidsalazar01
davidsalazar01
Posted Tuesday, September 07, 2010 9:31 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 3:49 PM
Points: 170,
Visits: 332
@LutzM:
The reply was actually directed to both you and John but I forgot to include your name on the posting as I was hurried to try to attach the XML docs and head out for the day to pick up my son from school. Please feel free to provide any more input and give any other suggestions as I'm really trying to get this resolved ASAP.
Thanks guys!
-David
Post #982017
John Rowan
John Rowan
Posted Wednesday, September 08, 2010 8:44 AM
Hall of Fame
Group: General Forum Members
Last Login: Tuesday, January 29, 2013 10:54 AM
Points: 3,837,
Visits: 3,821
Lutz, I agree...please stay on. I know that you have ample XML experience and could add value to this thread. Thus far, I've been poking around to try to get an idea of what David really wants to see for output. From one of your previous posts, I think you are correct in thinking that David wants to combine the results from both colujmns (which could contain different elements).
David,
Big question here. You've shown us 1 row from your table, but I've yet to see an example of how you want your result set to look like. Based on the sample data that you've now given us, can you show us what the results should look like. Specifically, please combine the sample data that you've shown us into one result set and post that as an example of what you want your query to return. Telling us is not the same as showing us. Too much gets lost in the interpretation of the problem; whereas, a sample result set speaks for itself and we can more redily give you help.
If needed, please read the article in the link from my signature line. It talks about properly setting up sample tables/data/results to get better/faster help.
John Rowan
======================================================
======================================================
Forum Etiquette: How to post data/code on a forum to get the best help
- by Jeff Moden
Post #982360
davidsalazar01
davidsalazar01
Posted Wednesday, September 08, 2010 11:00 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 3:49 PM
Points: 170,
Visits: 332
Lutz/John,
I've sent out a communication to the developer that requested this query to see if he can explain what needs to be shown in the result set. I'm awaiting a response. In the meantime I've attached the spec they sent me to get an idea of what they're trying to retrieve in the output to present in a Crystal report.
Thanks guys!
-David
Post Attachments
Amend EPOS Flight Details Report Spec.xlsx
(
10 views,
338.80 KB
)
Post #982498
maciej_p
maciej_p
Posted Friday, December 03, 2010 8:26 AM
Forum Newbie
Group: General Forum Members
Last Login: Tuesday, February 07, 2012 12:06 PM
Points: 1,
Visits: 17
Hey! Not sure if you still care, or if this is what you are looking for, but here it is anyway :)
This assumes you know the root element name. You can store output in temp tables or table variables and process it any way you want.
DECLARE @idoc INT
DECLARE @exml XML
DECLARE @Root VARCHAR(64)
SET @Root = '/YourRootName'
SELECT @exml = [YourXMLColumn] FROM YourTable
EXEC sp_xml_preparedocument @idoc OUTPUT, @exml
select
columnNames.id,
columnNames.localname AS ELEMENT,
columnValue.text AS VALUE
FROM OPENXML (@idoc, @Root) columnNames
cross apply (select text FROM OPENXML (@idoc, @Root)
where nodetype = 3 AND parentid = columnNames.id) columnValue
where columnNames.nodetype <> 3 and columnNames.localname not in ('xsi','xsd')
Exec sp_xml_removedocument @idoc
Post #1029908
davidsalazar01
davidsalazar01
Posted Friday, December 03, 2010 9:54 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 3:49 PM
Points: 170,
Visits: 332
Thanks for the reply. I used a another nasty SQL script to get the data I needed parsed from the XML docs that were stored in the table into another table so they could report on it. I appreciate your response.
I've attached the "ParseEPOSFlightDetail.txt" file for your review.
-David
Post Attachments
Parse_EPOSFlightDetail.txt
(
12 views,
8.77 KB
)
Post #1030019
« Prev Topic
|
Next Topic »
17 posts, Page 2 of 2
««
1
2
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.