How would I go about using the BuildRowsetFromXML function to parse a SOAP API Response that contains namespaces.

The examples that I've seen that use BuildRowsetFromXML use it for parsing a more simplified xml structure (//rss/channel/item/title) without namespaces or metadata.

I have the following source code below it outputs the value of the string representation for the status of the HTTP request as well as an attempts to parse the 'Description' attribute of the Holiday names web service.

1) The trouble I am having is I can't seem to figure out how to properly reference the nested tree in the soap:body. In most examples where I see BuildRowsetFromXML function being used to reference the nested elements of choice by designated the ( //soap/GetHolidaysAvailableResponse/GetHolidaysAvailableResult/[@i]/
HolidayCode/Description) as the root folder and accessing each subfolder in a manner similar to this but I get an error when I attempt this I get a row count of '0' so I am sure I am not accurately traversing the tree.

2) The other puzzling thing about this is when i set the content type to be 'text/xml' I am actually expected to see the brackets appearing as text in the callstatus string but I instead I just see the values jumbled together as one large string. Why would that be the case? Why wouldn't I see this as true xml and what do I need to do to make it appear so? I already tried setting the 'content type' to be 'application/xml' but that generated an 415 error for 'unsupported content media type'.

Can anyone provide a explanation of where I need to focus attention for a solution?

    var @payload,@endpoint,@callstatus,@callresponse, @httppost, @xml, @i, 
    @j, @names, @talents, @talent, @rowCount1, @rowCount2

    set @endpoint = 
    set @payload = '

    set @httppost = HTTPPost2(@endpoint,'text/xml', @payload, false, 
    @callstatus, @callresponse)=%%

    set @names = 
    set @rowCount1 = RowCount(@names)

    outputline(concat("<br>rowCount1: ",@rowCount1))
       for @i = 1 to @rowCount1 do

       Set @name = Field(Row(@names,@i), "Value")
       outputline(concat("<br><br>Description: ",@name))

    next @i

  • Shooting from the hip, but shouldn't the BuildRowsetFromXML be looking at @callresponse, not @callstatus? Also, I think it should be CONCAT('//soap/GetHolidaysAvailableResponse/GetHolidaysAvailableResult/[', @i, ']/HolidayCode/Description') - and finally - should it be ...Result/[@i]/ or should it be ...Result[@i]/? I don't see a sample of your XML that you are using the BuildRowsetFromXML on, so I am not sure on paths. Nov 19, 2018 at 22:41

1 Answer 1


I discovered that I needed to strip out all of the namespaces as well as the 'xmlns' attributes in order to get the BuildRowsetFromXML to successfully parse it. I see this function working for custom xml attributes so my guess is it has to do with the presence of colons and slashes found within the xmlns attributes that make this necessary. Here is the source code below.


var @displayXML, @payload, @endpoint, @callstatus, @callresponse, @httppost, 
@i, @path, @nodes, @rowCount, @nodepath, @holidayName

set @endpoint = 
set @payload = ""
set @payload = concat(@payload, '<soapenv:Envelope 
set @payload = concat(@payload, '<soapenv:Body>')
set @payload = concat(@payload, '<hs:GetHolidaysAvailable>')
set @payload = concat(@payload, 
set @payload = concat(@payload, '</hs:GetHolidaysAvailable>')
set @payload = concat(@payload, '</soapenv:Body>')
set @payload = concat(@payload, '</soapenv:Envelope>')

set @httppost = HTTPPost2(@endpoint,'text/xml', @payload, false, @callstatus, 

set @displayXML = Replace(@callstatus,'<?xml version="1.0" encoding="utf-8"? 
set @displayXML = Replace(@displayXML,':Body','')
set @displayXML = Replace(@displayXML,':Envelope','')
set @displayXML = Replace(@displayXML,' 
set @displayXML = Replace(@displayXML,' 
set @path = "/soap/soap/GetHolidaysAvailableResponse/GetHolidaysAvailableResult/HolidayCode"
set @nodes = 
set @rowCount = RowCount(@nodes)

if @rowCount > 0 then

for @i = 1 to @rowCount do

set @nodepath = concat(@path,"[",@i,"]/")

   if rowcount(BuildRowsetFromXML(@displayXML,concat(@nodepath,       
     > 0 then
     set @holidayName = 
     "Code"),0),1), 'Value')
     Output(concat("<br>US Holiday Name: ",@holidayName))

next @i



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .