Thanks for your reply, Deane. It should work from the code, but I don't
understand why it isn't. 
Annoying to me. Any pointers ?
 
-Ravi
 
 

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 08, 2004 10:28 AM
To: Ravinder Arepally
Cc: '[EMAIL PROTECTED]';
[EMAIL PROTECTED]; '[EMAIL PROTECTED]'
Subject: Re: FW: :DOM::Parser question !



Ravi, 

This seems like it ought to work--I do a lot of changing to an HTML file
using similar code: 

# assume that $line contains the text you're working with--a line from a
file--then... 
if ($line =~ /arg name = \"sample\"/) { 
    $line =~ s/true/false/; 
} 

HTH, 

Deane 




        Ravinder Arepally <[EMAIL PROTECTED]> 
Sent by: [EMAIL PROTECTED] 


06/08/2004 12:07 


        
        To:        "'[EMAIL PROTECTED]'"
<[EMAIL PROTECTED]> 
        cc:        "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]> 
        Subject:        FW: :DOM::Parser question !



All,

Any help regarding below problem is greatly appreciated.
My intention is to change value to true.

<javaTask className = "tool.update.languagepack.MergeConfig">
               <arg name="sample" value="false"/> 

                                                  to 

  <javaTask className = "tool.update.languagepack.MergeConfig">
               <arg name="sample" value="true"/>        


Thanks,
Ravi


-----Original Message-----
From: Ravinder Arepally 
Sent: Monday, June 07, 2004 5:56 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: XML::DOM::Parser question !

All,

I am trying to parse a XML file and change an element value. 
Below is code of mine where I am doing this. However, setAttribute doesn't
work and it doesn't give any error message too.
I spent enough time and doesn't make sense to me. I get right value using
getAttribute('value).
XML file is also pasted at the end of this mail. Any help or pointer is
greatly appreciated. 
Any suggestions in writing better code for this task is also appreciated.

Thank you,
Ravi.

---------------------------------------------------
my $udtTaskFile =
"$depotLocation/updates/$udtBaseName/tasks/$udtBaseName"."_cs_udt.xml";
print ("udtTaskfile is : $udtTaskFile \n");  ------- XML file which is
pasted at end of this mail.
Util::safeCopy("$udtTaskFile", "$udtTaskFile".time()); -- I have Util.pm 

my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile($udtTaskFile);

my @taskList = $doc->getElementsByTagName('taskEntry');

foreach my $task (@taskList) {
    if ($task->getAttribute('uniqueName') eq "MergeConfig"){
         my $javaTask = $task->getElementsByTagName('javaTask');
         if (! $javaTask) {
             $log->write("ERROR: Couldn't find any Java tasks in
$udtTaskFile ");
            return "Problem configuring installLPI. Couldn't find any Java
Tasks in $udtTaskFile. ";
         }
     my $innerTask = $javaTask->item(0)->getElementsByTagName('arg');
     if (! $innerTask) {
             $log->write("ERROR: Couldn't find any languagepack tasks in
$udtTaskFile ");
            return "Problem configuring installLPI. Couldn't find any
languagepack Tasks in $udtTaskFile. ";
     }
     my $value = $innerTask->item(0)->getAttribute('value');
     print ("value is 333333333333 $value \n");      -------- This prints
right value
     $innerTask->item(0)->setAttribute('value', "true");  ----- This is not
working. No error and it doesn't change value
    }
}


----------------------------------------------------------------------------
------------------------------



<!DOCTYPE harnessTaskList SYSTEM "harnessTaskList.dtd">
  <harnessTaskList extensionClassname = "tools.update.TaskHarnessExtForUDT"
                   logCategory = "update/info">
       <!-- Task UDT               Runs the update delivery tool        -->
       <taskEntry uniqueName   = "DiskSpace"
                  description  = "Checks if the necessary space is
available on disk to proceed with update"
                  logCategory  = "update/info"
                  canRerun     = "true">
           <javaTask className = "tools.update.DiskSpace"/>
       </taskEntry>
       <taskEntry uniqueName   = "UDT" 
                   description  = "Runs the update delivery tool"
                  dependency   = "DiskSpace"
                  logCategory  = "update/info"
                  canRerun     = "true">
           <javaTask className = "tools.update.UpdateDeliveryTool"/>
       </taskEntry>
       <taskEntry uniqueName   = "EnableLanguages"
                  description  = "Install files for language pack."
                  dependency   = "UDT"
                  canRerun     = "true"
                  logCategory  = "lpi/info">
           <javaTask className =
"tool.update.languagepack.EnableLanguage"/>
       </taskEntry>
       <taskEntry uniqueName   = "MergeConfig"
                  description  = "Merges language related files to config."
                  dependency   = "UDT, EnableLanguages"
                  logCategory  = "lpi/info"
                  canRerun     = "true">
           <javaTask className = "tool.update.languagepack.MergeConfig">
               <arg name="sample" value="false"/>          --------------
This is the value I am trying to change
           </javaTask>
       </taskEntry>
</harnessTaskList>

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Reply via email to