Extracting name value pairs from an XML string

Extracting name value pairs from an XML string

Post by Dave » Sat, 23 Aug 2003 01:34:05

I am having a difficult time createing a stored procedure that extracts name
value pairs from an XML string.

I need to extract both element and attribute values.  Here is an example of
the XML that is passed to the stored proc:

EXEC spCLASS_SaveHPAssets '<homepage realtorid="14042222">
  <homepagetab menutabid="1">Home</homepagetab>
  <homepagetab menutabid="20"></homepagetab>
  <homepagedetail attributeid="3" attributename="agadd1">3522 Oak
  <homepagedetail attributeid="5"
  <homepagedetail attributeid="6"
  <homepagedetail attributeid="7"


I need to be able to grab the following values:

homepagetypeid, 12
agadd, 3522 Oak Street

I seem to be able to get attribute values but not the element values.  For
example, the following gets all the "attributename" values but not the
associated "homepagedetail" values:

 With (


Does anyone have some sample code that illustrates how I can access both
type of values?