Solved

xmlnode no child nodes

Posted on 2004-10-04
5
201 Views
Last Modified: 2006-11-17
Hi
here is my xml document and want to get the Persons node with out Address node.

i mention the output format.
Can anybody have clue,please help me.

Ex:

<Persons>
      <Person>
            <FirstName></FirstName>
            <LastName></LastName>
            <Address>
                  <Line1></Line1>
                  <Line2></Line2>
            </Address>
            </Person>
            <Person>
            <FirstName></FirstName>
            <LastName></LastName>
            <Address>
                  <Line1></Line1>
                  <Line2></Line2>
            </Address>
            </Person>
            <Person>
            <FirstName></FirstName>
            <LastName></LastName>
            <Address>
                  <Line1></Line1>
                  <Line2></Line2>
            </Address>
            </Person>
</Persons>

OuPut :

<Persons>
      <Person>
            <FirstName></FirstName>
            <LastName></LastName>
            
            </Person>
            <Person>
            <FirstName></FirstName>
            <LastName></LastName>
            
            </Person>
            <Person>
            <FirstName></FirstName>
            <LastName></LastName>
            
            </Person>
</Persons>
0
Comment
Question by:pprasadravi
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
ramazanyich earned 250 total points
ID: 12221829
Try that xsl:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template match="/">
 <Persons>
 <xsl:apply-templates/>
 </Persons>
 </xsl:template>
 <xsl:template match="Person">
 <Person>
 <xsl:copy-of select="child::*[name() != 'Address']"/>
 </Person>
 </xsl:template>

</xsl:stylesheet>
0
 

Author Comment

by:pprasadravi
ID: 12237395
can we get the same with xpath query without using xsl.
0
 
LVL 19

Expert Comment

by:ramazanyich
ID: 12240894
No
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question