Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm using XML::XPath for a long time to parse xml, now the situation has come to modify the attribute value.

xml is available in a file, it will be very similar to this.

<AppName>

<Action AllDay='1'StartRace='1'/>

<StartPoint AM_PM='AM' Hours='09' Mins='30'/>

<EndPoint AM_PM='PM' Hours='06' Mins='30'/>

</AppName>

I have written a perl script to change the Hours of StartPoint tag,
use strict; use warnings; use XML::Twig; my $fileName = 'Conf.xml' my $twig = XML::Twig->new( twig_roots => { StartPoint => \&ReplaceAtriValue }, twig_print_outside_roots => 1, ); sub ReplaceAtriValue { my ($twig, $startPoint) = @_; if ( '09' eq $startPoint->att('Hours') ) { $startPoint->set_att( Hours => '12'); } $startPoint->print(); } $twig->parsefile($fileName);
Now $twig has the xml object. If I send this object($twig) to my SetWindow.pm which parse xml using XML::XPath, did not recognize $twig object.

Is there any possible way to convert XML::Twig object to XML::XPath object so that XML::XPath will parse values in the $twig object.

Actually I have using XML::XPath for long back hence I have to send the XML::XPath object to all my own *.pm like SetWindow.pm, at the same time i need to change the values of the attribute of the standard xml before sending to my own PMs.

Thanks in Advance

Any Help is much appreciated


In reply to Is there any possible way to convert XML::Twig object to XML::XPath object by rnd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found