Re: [xml] How do you detect if a xml file has a root node??



Thanks for your instant reply. But my requirement is if the first node
is the main node containing other nodes I need to ignore it. But if it
contains that data then I need to include it.

Can anyone suggest me a method to do it.

regards,
Jayashree

-----Original Message-----
From: Andreas Tscharner [mailto:andreas tscharner metromec ch] 
Sent: Friday, March 23, 2007 11:41 AM
To: Kali, Jayashree; xml gnome org
Subject: RE: [xml] How do you detect if a xml file has a root node??

Hi,

 

I have an xml file of the below format.

 

<!-some comment generated.."  -->

<Node1>data</Node1>

 

How do I detect if the file has a root node or not? 

This file HAS a root node, it's called "Node1"

I mean how do I make the difference between the below xml 
file and the above xml file.

 

<!-some comment generated.."  -->

<RootNode>

<Node1>data</Node1>

</RootNode>

The root node have different names. On your first example, it was
"Node1", and now it is "RootNode"


as I need to avoid the root node when I load the xml file.

Why? You can just ignore (or not) the first node after you have parsed
the file...

Best regards
        Andreas
-- 
Andreas Tscharner                          andreas tscharner metromec ch
------------------------------------------------------------------------
And the beast shall come forth surrounded by a roiling cloud of
vengeance. The house of the unbelievers shall be razed and they shall be
scorched to the earth. Their tags shall blink until the end of days.
                                            -- The Book of Mozilla 12:10




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]