Avatar of soozh
soozh
Flag for Sweden asked on

Traverse a simple xml to extract nodes

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>

Open in new window


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 ;

Open in new window


Thanks in advance!
XMLSQL

Avatar of undefined
Last Comment
ste5an

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ste5an

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23