xml-libxml

Perl, LibXML and Schemas

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 = $parse...

How do I use XML::LibXML to parse XML using SAX?

The only example code I have found so far is so old it won't work anymore (uses deprecated classes). All I need is something basic that demonstrates: Loading and parsing the XML from a file Defining the SAX event handler(s) Reading the attributes or text values of the element passed to the event handler ...

Cannot install XML::LibXML module on Windows

I am trying to use XPath to extract some HTML tags and data and for that I need to use XML::LibXML module. I tried installing it from CPAN shell but it doesn't install. I followed the instructions from CPAN site about the installation, that we need to install libxml2, iconv and zlib wrappers before installing XML::LibXML and it didn't ...

How do I install XML::LibXML for ActivePerl?

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 fir...

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

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 =...

Why can't I access elements inside an XML file with XPath in XML::LibXML?

I have an XML file, part of which looks like this: <wave waveID="1"> <well wellID="1" wellName="A1"> <oneDataSet> <rawData>0.1123975676</rawData> </oneDataSet> </well> ... more wellID's and rawData continues here... I am trying to parse the file with Perl's libXML and output the wellName and the rawDat...

Does XML::LibXML::Reader read HTML?

I didn't find anything about parsing HTML in the XML::LibXML::Reader documentation. And I tried to parse a HTML-site and it didn't work. Is my conclusion, that XML::LibXML::Reader doesn't work with HTML right? ...

Why doesn't Perl's XML::LibXML module (specifically XPathContext) evaluate positions?

I have an XML representation of a document that has the form: <response> <paragraph> <sentence id="1">Hey</sentence> <sentence id="2">Hello</sentence> </paragraph> </response> I'm trying to use XML::LibXML to parse a document and get the position of the sentences. my $root_node = XML::LibXML->load_xml( ... )->documentElem...

XML::LibXML Line Ending (whitespace) Problem.

HI, I am parsing an XML file using LibXML in Perl. The problem that I have is the ending characters (whitespace) is treated as a text node. For instance, given an input like the following <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE books [ <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT year (#PCDATA...

XML::LibXML: How to get a Number/Boolean-object with find?

From http://search.cpan.org/~pajas/XML-LibXML-1.70/lib/XML/LibXML/Node.pod: find evaluates the XPath 1.0 expression using the current node as the context of the expression, and returns the result depending on what type of result the XPath expression had. For example, the XPath "1 * 3 + 52" results in a XML::LibXML::Number object bein...

Is there a reason to use the XML::LibXML::Number-object in my XML::LibXML-example?

In this example I get to times '96'. Is there a possible case where I would need a XML::LibXML-Number-object to to achieve the goal? #!/usr/bin/env perl use warnings; use strict; use 5.012; use XML::LibXML; my $xml_string =<<EOF; <?xml version="1.0" encoding="UTF-8"?> <filesystem> <path> <dirname>/var</dirname> <files> ...

Is this a valid XPath expression?

Is this xpath a valid XPath expression? (It does what it should ). #!/usr/bin/env perl use strict; use warnings; use 5.012; use XML::LibXML; my $string =<<EOS; <result> <cd> <artists> <artist class="1">Pumkinsingers</artist> <artist class="2">Max and Moritz</artist> </artists> <title>Hello, Hello</title>...

Validating XML in Perl with libxml and an XSD file

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 => $s...

Searching nodes - Libxml

Hello all... I am trying to parse an XML document in C++. I do not have any form of metadata associated with the document. Since i am a novice with XML's i wanted to understand the best way to parse this xml. I am using libxml2 to achive this. What i am doing currently is 1) walking the complete tree node by node , using pointers of ...