libxml2

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

a 夏天 提交于 2019-12-04 06:33:28
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 common-name and an attribute called name. foreach my $camelid ($xpc->findnodes('//microplateML:species')

How to use libxml2 with python on macOs?

拜拜、爱过 提交于 2019-12-04 06:09:01
I'm on OSX Lion and I have libxml2 installed (by default) and I have python installed (by default) but they don't talk to one another. What's the simplest way to make this work on Lion? $ python -c "import libxml2" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named libxml2 tkone Visit ftp://xmlsoft.org/libxml2/python/ and ensure this is the latest version Download it unpack it open a term and cd to that directory type sudo python setup.py install ls /Library/Python/2.7/site-packages/ and you should see a bunch of libxml2 files try the test

How to use nokogiri from Jruby on Windows?

心已入冬 提交于 2019-12-04 05:14:52
问题 I'm getting the following error when trying to use Nokogiri with Jruby on Windows 7 D:\code\h4>jruby -e "require 'rubygems'; require 'nokogiri'" D:/jruby-1.3.1/bin/../lib/ruby/1.8/ffi/library.rb:18:in `ffi_lib': Could not ope n any of [xml2, xslt, exslt] (LoadError) from D:/jruby-1.3.1/lib/ruby/gems/1.8/gems/nokogiri-1.3.3-java/lib/nokog iri/ffi/libxml.rb:5 from D:/jruby-1.3.1/lib/ruby/gems/1.8/gems/nokogiri-1.3.3-java/lib/nokog iri/ffi/libxml.rb:31:in `require' from D:/jruby-1.3.1/bin/../lib

libxml2 from java

时间秒杀一切 提交于 2019-12-04 05:05:25
This question is somewhat related to Fastest XML parser for small, simple documents in Java but with a few more specifics. I'm working on an application which needs to parse many (10s of millions), small (approx. 300k) xml documents. The current implementation is using xerces-j and it takes about 2.5 ms per xml document on a 1.5 GHz machine. I'd like to improve this performance. I came across this article http://www.xml.com/pub/a/2007/05/16/xml-parser-benchmarks-part-2.html claiming that libxml2 can parse about an order of magnitude faster than any java parsers. I'm not sure if I believe it,

Can I incorporate system libraries (e.g. libxml2) I compile against into a gem (e.g. nokogiri) that I can deploy to Heroku?

这一生的挚爱 提交于 2019-12-04 04:10:26
Nokogiri has a problem with translating to and from UTF-8 characters that turns out to come from libxml2, specifically version 2.7.6, which is the highest supported version on Ubuntu 10.04 LTS. The bug is fixed in version 2.7.7 and up, but since our app is hosted on Heroku (bamboo-ree-1.8.7 stack, based on Ubuntu 10.04), we have to use version 2.7.6, and continue to experience the bug, unless: Someone can/has hacked nokogiri to get around the problem Canonical bumps the supported libxml2 version for Ubuntu 10.04 (and/or Heroku updates libxml2 in their stack) I can come up with a way for

Building the latest iconv and libxml2 binaries in Win32

假装没事ソ 提交于 2019-12-04 04:03:50
I'm trying to get MinGW and MSYS working so I can build iconv and libxml2 in Windows, but I'm finding ./configure and make are giving lots of BSD/Unix related errors that aren't specific enough to google, and not descriptive enough for me to figure out. Can anybody go through some of the steps needed to get iconv and libxml2 .dll/.lib built on a Win32 machine? I'm updating the libraries for some software and I fiddled around with this all day today and haven't figured it out. I got the newest libpng, zlib and curl built with no issues but I see there isn't much support or how-to's for these

Cannot install XML package in r

℡╲_俬逩灬. 提交于 2019-12-04 04:01:56
I'm trying to install "XML" package in r, but an error occurs. Please tell me what's wrong. OS: OS X 10.11.6 R version: 3.3.2 The error message when executing "install.packages("XML") is the following. * installing *source* package ‘XML’ ... ** package ‘XML’ successfully unpacked and MD5 sums checked checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C

How to use global namespace definitions in a fragment creation?

放肆的年华 提交于 2019-12-04 01:42:59
问题 The root element have namespace declarations like xmlns:xlink="http://www.w3.org/1999/xlink" ... so, any node appended (ex. by appendChild ) will accept the namespace. I can append <graphic xlink:href=".."/> because on the whole it is valid... But to append a fragment I need first to create the fragment with createDocumentFragment() . Example: $tmp = $dom->createDocumentFragment(); $ok = $tmp->appendXML('<graphic xlink:href="file123.ext"/>'); when running, generates an error,

How to parse a XML string instead of XML doc in c using libxml2 library

回眸只為那壹抹淺笑 提交于 2019-12-04 00:34:50
问题 All the examples in libxml2 documentation libxml tutorial are mentioned using external XML files. What if I need to parse a string with XML content in it? Is it really possible in libxml2 C library, or the only solution would be taking the string saving it to the file and sending that file name as argument to the below function. But it would seriously effect the performance. doc = xmlParseFile(docname); Are there any inbuilt functions in libxml2 to parse character arrays? 回答1: You can use

libxml2 xmlChar * to std::wstring

为君一笑 提交于 2019-12-03 20:34:37
libxml2 seems to store all its strings in UTF-8, as xmlChar * . /** * xmlChar: * * This is a basic byte in an UTF-8 encoded string. * It's unsigned allowing to pinpoint case where char * are assigned * to xmlChar * (possibly making serialization back impossible). */ typedef unsigned char xmlChar; As libxml2 is a C library, there's no provided routines to get an std::wstring out of an xmlChar * . I'm wondering whether the prudent way to convert xmlChar * to a std::wstring in C++11 is to use the mbstowcs C function, via something like this (work in progress): std::wstring xmlCharToWideString