Quantcast
Viewing all articles
Browse latest Browse all 2

Answer by Adam Spriggs for How can I keep missing XML elements from breaking my RSS-driven newsletter?

My suggestion would be to check the rowcount() first. I generally structure it like this, so you don't assume that all of the nodes have the same tags. You can nest this same structure as dictated by the structure of your XML.

%%[

 set @Nodes = BuildRowsetFromXML(@xml,"/collection/items/*",0)
 set @rowCount = rowcount(@Nodes)

 for @i = 1 to @rowCount do

     if rowcount(BuildRowsetFromXML(@xml,concat("/collection/items/item[",@i,"]/var1"),0)) > 0 then

      set @var1 = Field(Row(BuildRowsetFromXML(@xml,concat("/collection/items/item[",@i,"]/var1"),0),1),'Value')

     endif

     ]%%

     <br>@var1: %%=v(@var1)=%%

%%[ next @i ]%%

Viewing all articles
Browse latest Browse all 2

Trending Articles