get a xml node as-it-is

A

ArunDhaJ

i hve a xml like this:
<Students>
<Student name = "arun1" number="6">
<Student name = "arun2" number="7">
<Student name = "arun3" number="8">
<Student name = "arun4" number="9">
....
....
....
</Students>

i need to build a new xml or a string from this with few student
nodes.... some thing like this..

<Student>
<Student name = "arun2" number="7">
<Student name = "arun3" number="8">
</Student>

by selecting only the two nodes.........

is there any api which should return some thing like this ????
"<Student name = "arun2" number="7">"


Thanks
ArunDhaJ
 
M

Martin Honnen

ArunDhaJ said:
i hve a xml like this:
<Students>
<Student name = "arun1" number="6">

That is not well-formed, you need e.g.
said:
<Student name = "arun2" number="7">
<Student name = "arun3" number="8">
<Student name = "arun4" number="9">
...
...
...
</Students>

i need to build a new xml or a string from this with few student
nodes.... some thing like this..

<Student>
<Student name = "arun2" number="7">
<Student name = "arun3" number="8">
</Student>

by selecting only the two nodes.........

is there any api which should return some thing like this ????
"<Student name = "arun2" number="7">"

Use an XSLT stylesheet for instance that copies what you want to copy:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:eek:utput method="xml"/>
<xsl:template match="Students">
<xsl:copy>
<xsl:copy-of select="Student[@name = 'arun2' or @name = 'arun3']"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

You could as well use DOM programming to load the original document, the
delete the Student elements you are not interested in and then save
the DOM back.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top