[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?

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>

 

I need to know it before parsing the whole file,

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

So if the file is in the first format then I get wrong results..

 

regards,

Jayashree



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