populating template using xml

View: New views
1 Messages — Rating Filter:   Alert me  

populating template using xml

by satheeshsamiappan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I have a scenario where i need to load a template based on a XML file. I was able to load it using the vm template.

Now i need to use xpath expression to get a section of xml document. Is there a way to fetch portion of xml document using xpath expression.

I tried anakia, but still it is teasing.
eg:
#set ($studentList = $xpath.applyTo("document/student", $root))
#foreach( $student in $studentList)
$student
#end

When i use the above code in my vm template i'm able to get only the end nodes and not the values.
o/p:
[Element: <student/>]
[Element: <student/>]
[Element: <student/>]

without using xpath expression i'm able to get the desired  o/p.

my xml file looks like this
<document>
        <student>
                <rno>1</rno>
                <name>Komal</name>
                <marks>
                        <mark>80</mark>
                        <mark>90</mark>
                </marks>
        </student>
       ...
       ...
<document>