xml-libxml

Validating XML in Perl with libxml and an XSD file

我只是一个虾纸丫 提交于 2019-12-12 13:46:24
问题 I am trying to have my perl script get an Xxml file from online and validate it according to an XSD file. The code to do this is as follows: my $url = shift @ARGV; my $response = $ua->get($url) || die "Can't fetch file"; my $file = $response->content; my $schema_file = "schema.xsd"; my $schema = XML::LibXML::Schema->new(location => $schema_file); my $parser = XML::LibXML->new; my $doc = $parser->parse_string($file); eval { $schema->validate($doc) }; die $@ if $@; Running this results in a

Malformed UTF-8 character (fatal) error while parsing XML using XML::LibXML

一曲冷凌霜 提交于 2019-12-11 15:06:43
问题 I am parsing XML files using XML::LibXML. For the following XML entry I get the error: Malformed UTF-8 character (fatal) at C:/Perl64/site/lib/XML/LibXML/Error.pm line 217 which is $context=~s/[^\t]/ /g; The entry in XML is the following <MedlineCitation Owner="NLM" Status="MEDLINE"> <PMID Version="1">15177811</PMID> <DateCreated> <Year>2004</Year> <Month>06</Month> <Day>04</Day> </DateCreated> <DateCompleted> <Year>2004</Year> <Month>08</Month> <Day>11</Day> </DateCompleted> <DateRevised>

perl - remove node from xml file

非 Y 不嫁゛ 提交于 2019-12-11 02:13:43
问题 I have a XML file, and I want to read it - remove a node - save it. I run perl from terminal (perl script.pl) example XML (filename.xml): <?xml version="1.0" encoding="UTF-8"?> <twice> <inner> <twice> <name>John</name> <surname>Smith</surname> </twice> <twice> <name>Alan</name> <surname>Bowler</surname> </twice> <twice> <name>Michael</name> <surname>Deck</surname> </twice> </inner> </twice> example perl script (script.pl): use strict; use warnings; use XML::LibXML; my $filename = "filename

Change few characters only in a node value in XML using Perl script

∥☆過路亽.° 提交于 2019-12-08 13:26:46
问题 Original XML: <library> <email name="Peter P">Peter_Parker@library.com</email> </library> Expected Result: <library> <email name="Peter Parker">Peter.Parker@library.com</email> <address>London</address> </library> Further XML challenge: <library> <email name="Peter Parker">Peter.Parker@library.com</email> <address> <housenumber>1</housenumber> <street>Regent Street</street> <postcode>AB12YZ</postcode> </address> </library> Code: use strict; use XML::LibXML; use XML::LibXML::NodeList; my

XML::LibXML's notion of a text node's parent

守給你的承諾、 提交于 2019-12-07 14:56:11
问题 Something seems odd here. In the example below, I'm accessing text nodes via an XPath query ( //book/isbn/text() ). The text() is necessary to coerce XML::LibXML into allowing me to use the XML::LibXML::Text methods. To get to the parent node though, I have to invoke the parentNode method twice to get the true parent node ( <book> in this case): use strict; use warnings; use XML::LibXML; my $xml = XML::LibXML->new->parse_string( << 'MAIN' ); <library> <book> <title>Perl Best Practices</title>

Can't load 'C:/strawberry/perl/site/lib/auto/XML/LibXML/LibXML.dll' for module XML::LibXML

China☆狼群 提交于 2019-12-06 05:13:32
问题 I have downloaded strawberry PERL and writing one application with CGI Perl Apache on Winxp sp3). One of the libraries (written by someone else) which I using uses XML::LibXML. When i load the page it gives Internal Server Error. From Apache error log i can see this error: Can't load 'C:/strawberry/perl/site/lib/auto/XML/LibXML/LibXML.dll' for module XML::LibXML: load_file:The specified module could not be found at C:/strawberry/perl/lib/DynaLoader.pm line 190. C:/strawberry/perl/site/lib

perl script to iterate over xml nodes using XML::LibXML

不打扰是莪最后的温柔 提交于 2019-12-06 05:11:34
问题 I am trying to come up with a perl script to iterate over some nodes and get values in xml file. My XML File looks like below and is saved spec.xml <?xml version="1.0" encoding="UTF-8"?> <WO xmlns="http://www.example.com/yyyy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <WOSet> <SR> <FINISHTIME>2013-07-29T18:21:38-05:00</FINISHTIME> <STARTTIME xsi:nil="true" /> <TYPE>SR</TYPE> <DESCRIPTION>Create CUST</DESCRIPTION> <EXTERNALSYSTEMID /> <REPORTEDBY>PCAUSR</REPORTEDBY>

Missing files libresolv.9.dylib and libxml2.dylib

ぃ、小莉子 提交于 2019-12-04 23:24:23
问题 I have an old Xcode project for iOS where I used libxml2.dylib and libresolv.9.dylib. After installing XCode7. I can't find the files and I don't know where to search. Can someone help me? 回答1: SleepyViking's answer in this thread provides a shortcut to find missing .dylib files. Go to Build Phases > Link Binary with Librairies > + > Add other Once in the file selection window do "CMD"+Shift+G (Go to folder) and type /usr/lib/ From /usr/lib you can add : libz.dylib and more... Compile and

Perl, LibXML and Schemas

做~自己de王妃 提交于 2019-12-04 19:14:00
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 ($doc->findnodes('/library/book')) { my $title = $book->findnodes('./title'); print $title->to_literal(

perl script to iterate over xml nodes using XML::LibXML

倾然丶 夕夏残阳落幕 提交于 2019-12-04 10:27:25
I am trying to come up with a perl script to iterate over some nodes and get values in xml file. My XML File looks like below and is saved spec.xml <?xml version="1.0" encoding="UTF-8"?> <WO xmlns="http://www.example.com/yyyy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <WOSet> <SR> <FINISHTIME>2013-07-29T18:21:38-05:00</FINISHTIME> <STARTTIME xsi:nil="true" /> <TYPE>SR</TYPE> <DESCRIPTION>Create CUST</DESCRIPTION> <EXTERNALSYSTEMID /> <REPORTEDBY>PCAUSR</REPORTEDBY> <REPORTEDEMAIL /> <STATUS>RESOLVED</STATUS> <SRID>1001</SRID> <UID>1</UID> <SPEC> <AVALUE>IT</AVALUE> <ATTRID>CUST