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 =
'http://www.holidaywebservice.com//HolidayService_v2/HolidayService2.asmx?wsdl'
set @payload = '
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:hs="http://www.holidaywebservice.com/HolidayService_v2/">
<soapenv:Body>
<hs:GetHolidaysAvailable>
<hs:countryCode>UnitedStates</hs:countryCode>
</hs:GetHolidaysAvailable>
</soapenv:Body>
</soapenv:Envelope>'
set @httppost = HTTPPost2(@endpoint,'text/xml', @payload, false,
@callstatus, @callresponse)=%%
set @names =
BuildRowsetFromXML(@callstatus,
"//soap/GetHolidaysAvailableResponse/GetHolidaysAvailableResult/[@i]/
HolidayCode/Description",1)
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
]%%
@callresponse
, not@callstatus
? Also, I think it should beCONCAT('//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.