Re: Need help

Chaitanya Yanamadala <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
actually i have done it this way.

$outputfile=shift;
open(MYINPUT, "$outputfile"); # open for input
my(@lines1) = <MYINPUT>; # read file into list
my $value=5;
foreach $line_new (@lines1) # loop thru list
{
    if ($line_new =~ /HN_article/)
    {
        my ($value) = $line_new =~ /value="(.*?)"/;
        print $transaction."\n";
        my ($note) = $line_new =~ /note="(.*?)"/;
        print $reel_id."\n";

    if($value ne '' && $note ne '')
    {
        $xml_text .= '<a value"'.$value.'"note="'.$note.'"
tape_id="'.$value.'">';
    }
    else
    {
        $xml_text .= $line_new;
    }
    }
    else{
         $xml_text .= $line_new;
    }
}
close MYINPUT;
$outputfile_new="test.xml";
open(MYOUTPUT,">$outputfile_new") or die $!;
print MYOUTPUT $xml_text;
close MYOUTPUT;
use XML::DOM;

my $file = "test.xml";

# Read and parse the document
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ($file) or die $!;

#print $xml_text;


This is giving me my required output, but i want to do it using a XML
module, i dont know which one to use.

Chaitanya



On Mon, Jun 21, 2010 at 6:34 PM, Tod Harter <
[email protected]> wrote:

> Which XML library are you using?
>
> On Mon, Jun 21, 2010 at 6:05 AM, Chaitanya Yanamadala <
> [email protected]> wrote:
>
>> Hai
>>  I have a small query regarding to xml reading and writng..
>>
>> i have an xml like this
>> <a value="5" note=2 >
>> <b><c>hello</c></b>
>> </a>
>>
>> now i need to add a new attribute to node a.
>>
>> can any one help me how to do it..
>>
>> Chaitanya
>>
>>
>> _______________________________________________
>> Perl-XML mailing list
>> [email protected]
>> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>>
>>
>
>
> --
> The Wise adapts himself to the world. The Fool adapts the world to himself.
> Therefore, all progress depends on the Fool.
>

_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.