W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2000

Creating XML::DOM Tags

From: Guru Prasad <pnguruji@yahoo.com>
Date: Mon, 20 Nov 2000 16:50:34 +0530 (IST)
To: www-dom@w3.org
Message-ID: <Pine.LNX.4.20.0011201624180.12046-100000@Larry.bk>
Hi,

I am a newbie to XML-DOM. I have a peculiar problem in appending XML tags.
I am using Perl to work with XML. The Contents of the XML file is as
follows.

<XML_File>
<Data>
<Name>Mr. XYZ</Name>
<Address>Actual Address#1</Address>
</Data>

<Data>
<Name>Mr. ABC</Name>
<Address>Actual Address#2</Address>
</Data>
</XML_File>

I keyed in the above data in a file. Now how to actually create such tags
with values using perl scripts. I tried with
$Node = $Doc->getElementsbyTagName("XML_File")->item(0);
$DataNode = $Doc->createElement("Data")
$Node->appendChild($DataNode);

Now the above code is working and it created a instance of <Data></Data>.
But how to actually create tags under <Data>. I mean if i say 
getElementsbyTagName("Data"), Then i will get an multiple instance of
<Data>.I don't want to say getElementsbyTagName("Data")->item(0) b'coz
it would be very static. I want the DOM Parser to identify the last <Data>
instance that is created and it should return me so that i can do 
createElements under it.

Any suggestions/help would be great.

Thanks
guru.


  
Received on Monday, 20 November 2000 06:26:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT