Link to home
Start Free TrialLog in
Avatar of soozh
soozhFlag 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!
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial