libxml

What's the most efficient way to do recursive XPath queries using libxml2?

I've written a C++ wrapper function for libxml2 that makes it easy for me to do queries on an XML document: bool XPathQuery( const std::string& doc, const std::string& query, XPathResults& results); But I have a problem: I need to be able to do another XPath query on the results of my first query. Currently I do this by s...

How can I ignore a bad xmlns namespace with Perl's LibXML?

I have an XML document that references a namespace that is no available: <microplateDoc xmlns="http://moleculardevices.com/microplateML"&gt; ...my data is here... </microplateDoc> I have a script that reads it fine, but only when I delete the two above tags, otherwise it reads it all screwed up. Is it ok just to ignore it? I'm thin...

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

What's wrong with this eval statement in Perl?

What's wrong with this eval statement in Perl? I'm trying to check that the XML is valid by catching any exceptions thrown from the parsing of the file with XML::LibXML: use XML::LibXML; my $parser = XML::LibXML->new(); #creates a new libXML object. eval { my $tree = $parser->parse_file($file) # parses the file contents i...

What's wrong with this findnodes statement in my Perl's script?

I have a simple xml file that looks like this: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <microplateDoc xmlns="http://moleculardevices.com/microplateML"&gt; <camelids> <species name="Camelus bactrianus"> <common-name>Bactrian Camel</common-name> <physical-characteristics> <mass>450 to 500 kg.</mass> ...

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

How can I print out the attribute value instead of the element contents?

I have an XML file like this: <wave waveID="1"> <well wellID="1" wellName="A1"> <oneDataSet> <rawData>0.1123975676</rawData> </oneDataSet> <well> I am trying to print out the wellName attribute with the following code: my @n1 = $xc->findnodes('//ns:wave[@waveID="1"]'); # so @n1...

What is the correct Xpath query to access an element in Perl's XML::LibXML?

I'm trying to access an element called raw data, inside some <rawData>data is here</rawData> tags. However this XPath query with Perl's XML::LibXML is not working: foreach my $m ($xc->findnodes(q<//ns:wave[@waveID='1']/ns:well/oneDataSet/rawData>)) { print $m->textContent, "\n"; } but a similar query to get an attribute @wellName...

libxml converts accented characters into backlash x escapes. Json is not happy

I have the following attribute in an xml node I'm reading with libxml. It prints out normally with the accented character if I print out reader.node. reader = XML::Reader.new(File.open("somefile.xml", "r")) reader.read reader.read ... p reader.node => ... Full_Name="Univisión Network - East Feed" ... If I do this, though, it comes o...

iPhone SDK XML Parsing Attribute VS Nested elements

Hi all, I'm experiencing some performance problem using XML parser with iphone sdk. I tried to use LibXML parser directly and the NSXMLParser, but i had the same results. Now I'm looking for something that can improve parsing performance. Moving attributes to a nested elements can make it faster? I got an XML source file like this: <...

How do you use the --pattern option of xmllint?

I'm trying to see how libxml implements XPath support, so it made sense to me to test using xmllint. However, the obvious option, --pattern, is somewhat obscure, and I ended up using something like the following: test.xml: <foo><bar/><bar/></foo> > xmllint --shell test.xml / > dir /foo ELEMENT foo / > dir /foo/* ELEMENT bar ELEMENT b...

Using XML::LibXML: How do I create namespaces and child elements and make them work together?

I'm trying to do some stuff with FOAF and Perl. I'm unhappy with the current solutions and I want to roll my own. Please do not reference any module other than XML::LibXML. For reference here is a snippet from a FOAF file <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/...

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

How can I extract the desired nodes from this XML file using Perl and XPath?

After executing a XPath expression for extracting all year and value elements associated with death rates from a XML DB file, I want to take each node from the node list and find the year node, print that, find the value node, and print that all separately. The problem is that the output does not show anything. The XML content looks li...

libxml-ruby failed to load at x86_64

We are having problem with libxml-ruby gem at the server side Possible because it uses x86_64 architecture: $ uname -a Linux ip-10-228-171-64 2.6.21.7-2.fc8xen-ec2-v1.0 #1 SMP Tue Sep 1 10:25:30 EDT 2009 x86_64 GNU/Linux require 'libxml' LoadError: /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.4/lib/libxml_ruby.so: ...

PHP and XSLTProcessor Misbehavior

Hi all, Simple question: Why is a PHP function called from an XSL Stylesheet just returning the last argument passed: foo.xsl: <xsl:template match="/"> <xsl:value-of select="php:function('date','c')" /> </xsl:template> PHP: ... $xsl = new XSLTProcessor(); $xsl->registerPHPFunctions(); $xsl->importStylesheet($fooStylesheet); e...

[BUG] Bus Error - What causes this in Ruby?

I have run into this error 5 or 10 times over the past few years and have never found a clear answer to this problem. Here is the error: $ rake db:migrate /usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.9.5/lib/libxml_ruby.bundle: [BUG] Bus Error ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0] Abort trap The app I am running thi...

XML Namespace Problem

Is there a way to ignore XML namespaces with libxml? My problem is that the namespaces are incrementally named (i.e. ns1:, ns2:, ns3:, ns4:) depending on the records returned. This will error of I don't declare the namespace prior to parsing the data, any ideas would be much appreciated... ...

How to access xmlParserCtxt structure from within xmlSAXHandler callbacks?

I'm parsing (X)HTML pages content with libxml using the following call: htmlDocPtr doc = htmlSAXParseDoc(content, NULL, &html_handler, NULL); But for debugging purposes I need to analyze some of the current node properties in the start/end element callbacks. I know that the fourth argument of htmlSAXParseDoc can be used to pass any us...

How to solve Memory leaks in Lib Xml Parser in objective-C where the list is returned?

Hi Guys, I got leaks in Lib Xml Parser while retrieving the data from the net, Here in the below code, I have allocated the list - (void)getCustomersList { // make an operation so we can push it into the queue SEL method = @selector(parseForData); NSInvocationOperation *op = [[NSInvocationOperation alloc] initWithTarget:self selector...