troubleshooting Question

Traverse a simple xml to extract nodes

Avatar of soozh
soozhFlag for Sweden asked on
XMLSQL
1 Comment1 Solution72 ViewsLast Modified:
In a stored procedure i receive an XML as a parameter.  It looks like:

<root>
  <id>55408</id>
  <id>60179</id>
  <id>60640</id>
  <id>61787</id>
</root>

I need to do some processing on each <id> tag.  My first thought was to place them in a temporary table and then use a cursor to read each one and do the neccessary processing.

However there may be a way to traverse the XML in a cursor like scenario so i do not need the temporary table and you are welcome to suggest a solution.

How would extract each <id> tag and place it in a temporary table?

I am thinking:

Traverse the xml, extract <id> tag, and create a temp table

Create cursor to traverse table

While cursor returns data DO
begin
  Process the current <id>.
end ;

Thanks in advance!
ASKER CERTIFIED SOLUTION
ste5an
Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros