xml-libxml

XML::LibXML issue finding XML nodes with a namespace

被刻印的时光 ゝ 提交于 2020-12-26 08:21:26
问题 I am writing an XML parser and am having an issue with the program handling a link. I am attempting to parse an XML hierarchy Settings/Setting then findnode 'Value'. The following is an example of the XML: <?xml version='1.0' ?> <Settings xmlns='http://hme.com/Settings.xsd'> <Setting SID="0"> <Name>Store ID</Name> <Value>72</Value> </Setting> <Setting SID="1"> <Name>Deprecated</Name> <Value>0</Value> </Setting> <Setting SID="8"> <Name>Open Store Hours Sunday</Name> <Value>25200</Value> <

Perl XML::LibXML replace text

眉间皱痕 提交于 2020-03-21 10:46:06
问题 Simple xml file cr.xml <book_reviewers> <results> <reviewer> <name>Anne</name> <profession>Catfish wrangler</profession> </reviewer> <reviewer> <name>Bob</name> <profession>Beer taster</profession> </reviewer> <reviewer> <name>Charlie</name> <profession>Gardener</profession> </reviewer> </results> </book_reviewers> I want to loop through each reviewer and replace the name with a new one I am not trying to use both these methods, but going by other posts in the form both of these should work

Perl - XML::LibXML - getting elements that have certain attributes

狂风中的少年 提交于 2020-01-16 00:34:09
问题 I have a problem I am hoping someone can help with... I have the following example xml structure: <library> <book> <title>Perl Best Practices</title> <author>Damian Conway</author> <isbn>0596001738</isbn> <pages>542</pages> <image src="http://www.oreilly.com/catalog/covers/perlbp.s.gif" width="145" height="190" /> </book> <book> <title>Perl Cookbook, Second Edition</title> <author>Tom Christiansen</author> <author>Nathan Torkington</author> <isbn>0596003137</isbn> <pages>964</pages> <image

Perl, LibXML and Schemas

佐手、 提交于 2020-01-01 19:22:15
问题 I have an example Perl script which I am trying to load and validate a file against a schema, them interrogate various nodes. #!/usr/bin/env perl use strict; use warnings; use XML::LibXML; my $filename = 'source.xml'; my $xml_schema = XML::LibXML::Schema->new(location=>'library.xsd'); my $parser = XML::LibXML->new (); my $doc = $parser->parse_file ($filename); eval { $xml_schema->validate ($doc); }; if ($@) { print "File failed validation: $@" if $@; } eval { print "Here\n"; foreach my $book

Is XML::LibXML not supported on Perl 5.8.8?

倖福魔咒の 提交于 2019-12-31 02:55:12
问题 I answered a question on SO a while back where I initially suggested using XML::DOM. After mirod suggested that I use XML::LibXML instead, I implemented it. And to be honest, it works great on my system. I saw my runtime drop drastically with the new module without doing any additional optimizations. Now the tricky part, for some reason the module doesn't even install on my colleagues system. ppm install xml-libxml returns: Downloading ActiveState Package Repository packlist...not modified

Why is my XML file empty after generating with XML::LibXML

假如想象 提交于 2019-12-25 07:06:18
问题 This is my perl script #!/usr/bin/perl use XML::LibXML; $doc = XML::LibXML::Document->new; my $root = $doc->createElement("log"); $root -> setAttribute("time" => "now"); my $tag = $doc->createElement("greeting"); my $value = "hello"; $tag -> appendTextNode($value); $root -> appendChild($tag); $doc -> toFile('test.xml'); However, the output file test.xml only consists of this line: <?xml version="1.0"?> I assume that this means that the xml file is created but nothing is added to it. I don't

Remove XML namespaces with XML::LibXML

眉间皱痕 提交于 2019-12-24 01:18:56
问题 I'm converting an XML document into HTML. One of the things that needs to happen is the removal of namespaces, which cannot be legally declared in HTML (unless it's the XHTML namespace in the root tag). I have found posts from 5-10 years ago about how difficult this is to do with XML::LibXML and LibXML2, but not as much recently. Here's an example: use XML::LibXML; use XML::LibXML::XPathContext; use feature 'say'; my $xml = <<'__EOI__'; <myDoc> <par xmlns:bar="www.bar.com"> <bar:foo/> </par>

How can I access attributes and elements from XML::LibXML in Perl?

让人想犯罪 __ 提交于 2019-12-21 12:55:23
问题 I am having trouble understanding / using name spaces with XML::LibXML package in Perl. I can access an element successfully but not an attribute. I have the following code which accesses an XML file (http://pastebin.com/f3fb9d1d0). my $tree = $parser->parse_file($file); # parses the file contents into the new libXML object. my $xpc = XML::LibXML::XPathContext->new($tree); $xpc->registerNs(microplateML => 'http://moleculardevices.com/microplateML'); I then try and access an element called

How do I install XML::LibXML for ActivePerl?

懵懂的女人 提交于 2019-12-19 19:41:10
问题 I am new to Perl and I am using ActivePerl. I am getting the following error: Can't locate XML/LibXML.pm in @INC... I have tried everything but cannot find the steps to install the "correct" module for XML::LibXML. Here is exactly what is going on. I am running a script from a command prompt: c:\temp>perl myscript.pl The first few lines of myscript.pl: #!/usr/bin/perl use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); use HTTP::Date; use XML::Parser; use LWP::UserAgent; use XML::LibXML; use

XML::LibXML replace element value

 ̄綄美尐妖づ 提交于 2019-12-17 19:49:05
问题 I want to replace a "VAL1" value of an element in xml file For some reason it does not work for me: <testing> <application_name>TEST</application_name> <application_id>VAL1</application_id> <application_password>1234</application_password> </testing> my $parser =XML::LibXML->new(); $tree =$parser->parse_file($xml); $root =$tree->getDocumentElement; my ($elem)=$root->findnodes('/testing/application_id'); $elem->setValue('VAL2'); The errror is get is "Can't locate object method "setValue" via