I'm new with XML in SFMC, and I'm not sure if someone tried to execute the type of scenario, but I'm stuck with understanding the process of parse an XML payload form inside the SMFC. Is it even feasible to execute?

I've got a soap API triggered an XML payload to a designated triggered DE. In this particular DE, I can see the XML payload which has all the value loaded into a column. Now I want to extract some value out of this XML that is in the column. Is it even possible? How can you do it?

I read multiple time on the forum that you can parse an XML from SSJS. I'm not familiar with the functionality of it. Can the SSJS activity extra those XML values and create an automated process to push those value into a custom DE?

  • 1
    what did you try so far – pkharries Jul 4 '18 at 5:17
  • Have you read this? salesforce.stackexchange.com/questions/170754/… – Johannes Schapdick Jul 4 '18 at 5:48
  • @pkharries I already try AMPscript but this for the template view, and I'm trying to push those value to a template. I'm trying to parse and add to a new DE and separate the XML value into a new DE. Any idea how can this possibly could work? – renaud AGL Jul 5 '18 at 15:53
  • Thanks @JohannesSchapdick! I did look at this solution, and I kind of understood how the column are getting parse into indivdual rows. However, I don't understand the SSJS line that call the DE with the XML column? and SSJS line that push those individual XML values into an new target DE? – renaud AGL Jul 5 '18 at 16:02

The BuildRowSetFromXML() function is what makes this possible in AMPscript. You'll see a bunch of examples around here if you search for it. Here's an abandoned shopping cart example that parses an XML payload.


var @xml, @isXML, @nodes, @rowCount
set @xml = AttributeValue("xml")

if indexOf(@xml,"<cart>") > 0 then

  set @nodes = BuildRowsetFromXML(@xml,"/cart/items/item",0)
  set @rowCount = rowcount(@nodes)

  if @rowCount > 0 then

    for @i = 1 to @rowCount do

      var @sku
      var @name
      var @url

      set @nodepath = concat("/cart/items/item[",@i,"]/")

      if rowcount(BuildRowsetFromXML(@xml,concat(@nodepath,"sku"))) > 0 then
          set @sku = Field(Row(BuildRowsetFromXML(@xml,concat(@nodepath,"sku"),0),1),'Value')

      if rowcount(BuildRowsetFromXML(@xml,concat(@nodepath,"name"))) > 0 then
          set @name = Field(Row(BuildRowsetFromXML(@xml,concat(@nodepath,"name"),0),1),'Value')

      if rowcount(BuildRowsetFromXML(@xml,concat(@nodepath,"url"))) > 0 then
          set @url = Field(Row(BuildRowsetFromXML(@xml,concat(@nodepath,"url"),0),1),'Value')

      if not empty(@sku) and not empty(@name) and not empty(@url) then


       <br><a href="%%=redirectto(@url)=%%">%%=v(@sku)=%%</a> - <a href="%%=redirectto(@url)=%%">%%=v(@name)=%%</a>



    next @i


   outputline(concat("<br>no products found"))



  outputline(concat("<br>no XML found"))


  • Thank you @adamspriggs, but it's not really what I'm trying to accomplish. I had the chance to look at those examples for sure. I want to know if there is a way to parse XML without using AMPscript. – renaud AGL Jul 5 '18 at 15:42
  • I need to create a join SQL activities from a DE containing product URL and join to the other DE that contain the XML column. I want to join to the SKUs value in side XML. The only way to maybe accomplish this will be to first Parse the XML into a new DE and push those values into individual columns. I don't know if even it's posssible. – renaud AGL Jul 5 '18 at 15:49
  • You didn't mention SQL activities in your question. XML parsing is best done with AMPscript or SSJS in SFMC. Perhaps you can revise your question with some additional details about why it has to be done in an Automation. – Adam Spriggs Jul 5 '18 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.