Re: [Boston.pm] [Discuss] perl and xml
On BOSTON-PM-list, Mon, Oct 16, 2017 at 10:54 AM, Morse, Richard E.,MGH(who was away last week) replied: > Hi! I was just working with some XML, and I’d like to suggest also looking at > XML::XPath, > which does allow you to change the text content (and probably all the other > attributes) of nodes. > Also, since you can find nodes using XPath, it may be easier to select nodes, > rather than walking > through a tree of Perl structures… Yes. XML::XPath is basically what XML::Twig is a light-weight "do the easy 80% of" version of. (If one needs more than Twig, or if Twig docs don't make sense, XPath is obvious next choice.) -- Bill Ricker bill.n1...@gmail.com https://www.linkedin.com/in/n1vux ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm
Re: [Boston.pm] [Discuss] perl and xml
> On Oct 9, 2017, at 3:20 PM, Bill Ricker via Boston-pm> wrote: > > So you want to edit XML locally, replacing a tag's text contents with > a specific portion of the text contents of a specifically-named > sibling tag. > > For local edits such as you need, I'd use XML::Twig [2][3]. > I did a worked example [1] not so very different from yours for the > Perl Advent calendar in a prior decade (when Boston.PM's Jerrad Pierce > was editor and Boston.PM were majority contributors). Hi! I was just working with some XML, and I’d like to suggest also looking at XML::XPath, which does allow you to change the text content (and probably all the other attributes) of nodes. Also, since you can find nodes using XPath, it may be easier to select nodes, rather than walking through a tree of Perl structures… RIcky The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail. ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm
Re: [Boston.pm] [Discuss] perl and xml
On Mon, Oct 9, 2017 at 1:49 PM, R. Luomawrote on BLU Discuss: > This may be off-topic, but I am trying to manipulate > what I think is an "xml" file with perl (on a linux system). > I am not familiar with the ins and outs of xml It would not be off-topic on boson...@mail.perl.org . We're your local Perl UG. (Second Tuesdays, around the corner from where BLU meets. Tomorrow night, come visit!) Weren't you formerly on our Listserve too? (So I'm CC:ing discussion there, but folks there should REPLY ALL, so that he can see the replies.) > Supposedly, perl has xml modules for this purpose, Yes. > but I am have difficulty figuring them out. In Perl's spirit of TIMTOWTDI, There is More than One Way to Do It. The default answer is to parse an entire document and navigate the DOM from the root. That could be XML::LibXML or XML::Simple or XML::LibXSLT or ... That way lies madness, when your edits are strictly local. > The above example is simple, but, ultimately, > I would be working on an xml file with many items > and each item would have many different tags. So you want to edit XML locally, replacing a tag's text contents with a specific portion of the text contents of a specifically-named sibling tag. For local edits such as you need, I'd use XML::Twig [2][3]. I did a worked example [1] not so very different from yours for the Perl Advent calendar in a prior decade (when Boston.PM's Jerrad Pierce was editor and Boston.PM were majority contributors). [1] http://perladvent.pm.org/2009/06 [2] https://metacpan.org/module/XML::Twig [3] http://xmltwig.org/xmltwig/ -- Bill Ricker bill.n1...@gmail.com a/k/a bric...@theperlshop.com Facilitator, Boston Perl Mongers http://Boston.PM.org Consultant, ThePerlShop.com https://www.linkedin.com/in/n1vux ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm