Java Mailing List Archive

Home » FreeMarker-user »

Re: [FreeMarker-user] Get Node Value from Attribute

Daniel Dekany


Replies: Find Java Web Hosting

Author LoginPost Reply
Thursday, March 8, 2012, 1:09:05 PM, pchainarong wrote:

> Hi all,
> Please help me how to access the value of Node that has attribute
> @label='LastClase'.
> Let say my data like this
> <header>
>  <data label="CompanyName">Telstra Corporation Limited</data>
>  <data label="GICSIndustry">Diversified Telecommunication Services</data>
>  <data label="LastClose">3.25</data>
>  <data label="GICSIndustryGroup">Telecommunication Services</data>
>  <data label="GICSSector">Telecommunication Services</data>
> </header>
> I can access it from <data> index like ${doc.header.doc[2]} but I don't know
> how to access it from @label value.
> I try many ways but still got error
> ${[@(protected)']}
> ${']}
> ${["@(protected)'"]}
> Please help.....

This is doable with an XPath query. Let's assume you have a variable
called doc that contains the XML document, and then you could use this


The result will be the *list* of matching "data" elements. So if
there's no match, it will be an empty list. (If there's exactly 1
match, the result also can be used as a single value which is the same
as the first item of the list.)

Best regards,
Daniel Dekany

Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
FreeMarker-user mailing list
©2008 - Jax Systems, LLC, U.S.A.