Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

xmlnode no child nodes

Posted on 2004-10-04
5
Medium Priority
?
208 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
3 Comments
 
LVL 19

Accepted Solution

by:
ramazanyich earned 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses

783 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