1

I have a data extension in ExactTarget where in one of the fields we have XML code from where I have to extract specific info to print it out in an email newsletter.

E.g.:

FirstName: James
Last Name: Smith
XML: <root><Item count='97' member_id='123456' priority='1' type='CarIDrive' ></Item><Item count='97' member_id='7890123' priority='2' type='PlacesILike' ></Item><Item count='69' member_id='765432378' priority='3' type='GasPerMile' ></Item></root>

So the excel data files has the above headers: FirstName LastName XML

In the HTML email we will have a couple of places where the copy will be populated dynamically through AMPscript. e.g. FirstName, LastName, CarIDrive, PlacesILike and GasPerMile.

How can I assign variables to CarIDrive, PlacesILike and GasPerMile from the XML code from the data extension so I can call these variables in my HTML email?

Thanks, Vic

1 Answer 1

1

Use the BuildRowSetFromXML(S1,S2,B1)

Given the XML

<root>
  <Item count='97' member_id='123456' priority='1' type='CarIDrive' ></Item>
  <Item count='97' member_id='7890123' priority='2' type='PlacesILike' ></Item>
  <Item count='69' member_id='765432378' priority='3' type='GasPerMile' ></Item>
</root>

You would do this:

set @rowset = BuildRowsetFromXml(@xml, "//Item", 1)

Resulting in the rowset:

Value    XML    member_id_att   priority_att  type_att
 ""      ""     123456          1             CarIDrive
 ""      ""     7890123         1             PlacesILike
 ""      ""     765432378       1             GasPerMile

Access the attributes like normal, or loop through etc:

set @member_id = Field(Row(@rowset, 1), 'member_id_att')
8
  • I saw this @Kelly in the documentation:<br/> help.exacttarget.com/en/documentation/exacttarget/content/… question is what should I do after. Can you help?
    – Snowalker
    Apr 25, 2014 at 18:20
  • Correct - that should be what you want to do. Apr 25, 2014 at 18:20
  • There is a link to that in the function name. Apr 25, 2014 at 18:21
  • so you're saying if I create this variable e.g. [at]member_id_att and assign it Set [at]member_id_att = [member_id_att] will spit out 123456 for the lookuprow #1?
    – Snowalker
    Apr 25, 2014 at 18:26
  • also the XML is in the data file in the fields from the column called XML. If I retrieve only the value on that column it's going to be the whole XML code.
    – Snowalker
    Apr 25, 2014 at 18:35

You must log in to answer this question.

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