UPDATE: I broke down and rewrote my code using twig, it's *amazing*. Thanks for the suggestion and a special thanks for those who took the time to provide solutions.
I can't seem to find out how to use XML::Xpath to change the value of priority on the includes in the xml below.
I thought this would be simple, but I'm surprised at how stuck I seem to be getting. I'd strongly prefer using XML::XPath and not some other lib.
<includes>
<include>
<priority>9990</priority>
<required>true</required>
<location>/efs/dist/tpcommon/itrstemplates/latest/common/templ
+ates/equities.xml</location>
</include>
<include disabled="true">
<priority>10001</priority>
<required>true</required>
<location>/efs/dist/itrs/tools/latest/common/templates/global_
+authentication.xml</location>
</include>
</includes>
--
Code snippet below -
my $path = '//includes/include';
my $nodes = $xp->find($path);
for my $include ($nodes->get_nodelist) {
my $priority = $xp->find('./priority', $include);
my $location = $xp->find('./location', $include);
print "Location = " . $location->string_value;
print ", with Priority = " . $priority->string_value . "\n";
## I want to change this priority value to +1
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.