Freemarker XML parsing with attributes and value -
i have following xml contains 2 attributes , value. value containing content wrapped in field tag.
<field key="title" primitive="string"> <![cdata[ problem i'm trying solve. ]]> </field>
after parse it, when type ${item} in freemarker template. can attributes using item.@key , item.@primitive. unfortunately, i'm failing value or content. alternative solution use substring content value array. i'm sure freemarker has way sort of data.
field[attributes={key=title, primitive=string}; value=[this problem i'm trying solve.]]
assuming item
holds field
xml element, ${item}
should work. output show isn't familiar me. guess there's strange xml wrapping there, perhaps using of legacy xml wrappers. should use w3c dom element
or document
added data model, or wrapped explicitly freemarker.ext.dom.nodemodel
.
btw, can try on http://freemarker-online.kenshoo.com/ indeed should work, if fill form this:
template:
<#assign item=doc.field> ${item}
data model:
doc= <field key="title" primitive="string"> <![cdata[ problem i'm trying solve. ]]> </field>
Comments
Post a Comment