libxml2

DOM in PHP: Decoded entities and setting nodeValue

浪尽此生 提交于 2019-12-23 17:08:28
问题 I want to perform certain manipulations on a XML document with PHP using the DOM part of its standard library. As others have already discovered, one has to deal with decoded entities then. To illustrate what bothers me, I give a quick example. Suppose we have the following code $doc = new DOMDocument(); $doc->loadXML(<XML data>); $xpath = new DOMXPath($doc); $node_list = $xpath->query(<some XPath>); foreach($node_list as $node) { //do something } If the code in the loop is something like

Error while linking libxml2

强颜欢笑 提交于 2019-12-23 12:07:44
问题 I have a simple example for libxml2 but it returns the following error: $ gcc -Wall -lxml2 -I/usr/include/libxml2 -o ex1 ex1.c /tmp/cc6OKSKJ.o: In function `main': ex1.c:(.text+0x60): undefined reference to `xmlReadFile' ex1.c:(.text+0x70): undefined reference to `xmlDocGetRootElement' collect2: ld returned 1 exit status $ xml2-config --libs -lxml2 $ xml2-config --cflags -I/usr/include/libxml2 I'm on Lubuntu 11.10 x86_64 and I have all the packages I need (well I think): libxml2, libxml2-dev,

How to “refresh” DOMDocument instances of LibXML2?

风格不统一 提交于 2019-12-23 05:29:20
问题 Using PHP to illustrate: there are a BUG in the normalizeDocument() method, or a lack of a "refresh" method, because DOM consistence is lost after changes (even only attribute changes)... So, any algorithm "with DOM changes" that you implement with LIBXML2 somethimes works and sometimes not, is unpredictable!! (?) The "refresh" by $doc->LoadXML($doc->saveXML()); is a workaround and lost performance in a flow of work with DOM... A sub-question: all moment I need to refresh DOM? $XML = ' <html>

Injecting a string into an XML node without content escaping

隐身守侯 提交于 2019-12-23 03:52:20
问题 I'm generating some xml in code (as a string) and I want to set the string then as the sub elements of an existing node (using xmlNodeSetContent ). The problem is that either the xmlNodeSetContent function or the XML saving function I'm using ( xmlSaveFormatFileEnc ) is escaping the '<' and '>' characters as '& lt;' and '& gt;' How do I switch the escaping off in this instance? Or, can I format the string to disable the escaping? Possible answer: One solution I have tried is to add the

Disable debug output in libxml2 and xmlsec

拈花ヽ惹草 提交于 2019-12-23 02:35:09
问题 In my software, I use libxml2 and xmlsec to manipulate (obviously) XML data structures. I mainly use XSD schema validation and so far, it works well. When the data structure input by the client doesn't match the XSD schema, libxml2 (or xmlsec) output some debug strings to the console. Here is an example: Entity: line 1: parser error : Start tag expected, '<' not found DUMMY<?xml ^ While those strings are useful for debugging purposes, I don't want them to appear and polute the console output

xmlParseFile vs xmlReadFile (libxml2)

半腔热情 提交于 2019-12-22 14:52:27
问题 I'm writing some C code using the libxml2 library to read an XML file. There seem to be two different functions for this purpose, xmlParseFile and xmlReadFile, and and I'm not sure of the difference between them (besides the fact that xmlReadFile() takes some additional parameters). The examples on the libxml2 website sometimes use xmlParseFile and some use xmlReadFile. So when should you use xmlParseFile and when should you use xmlReadFile? I haven't been able to find anything that explains

Permission denied installing libxml2

帅比萌擦擦* 提交于 2019-12-22 09:59:48
问题 So I'm working on updating my rails environment to support 4.0 and ruby 2.0. So far I've had some trouble installing libxslt. When run in the terminal I get: $ brew install libxml2 Error: Permission denied - /usr/local/lib/python2.7/site-packages/sitecustomize.py I'm running this as a root user so the permission denied message is quite puzzling. Any help is appreciated. 回答1: You shouldn't install things to /usr/local as root or via sudo . From the FAQ Why does Homebrew say sudo is bad?

libxml2 missing for nokogiri gem on Windows 8 x64 with Ruby 1.9.3

老子叫甜甜 提交于 2019-12-22 03:22:47
问题 What I found searching for similar issues was that Nokogiri does not yet have x64 support with Ruby 2.0 . However although I'm on a Windows x64 machine my Ruby version is ruby 1.9.3p392 (2013-02-22) [i386-mingw32] from railsinstaller.org (with Rails 3.2.13) . This also means DevKit is already installed. gem install nokogiri --pre gives this error: Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR:

Getting nokogiri to use a newer version of libxml2

丶灬走出姿态 提交于 2019-12-21 13:35:32
问题 I've been trying to get Nokogiri installed on my computer (Mountain Lion) to use with rspec and capybara, but for the life of me, I can't get it to run properly. From what I can tell, the issue is with nokogiri using the wrong version of libxml2. I've so far tried uninstalling and reinstalling libxml2 using Homebrew (making sure it's the most recent one), uninstalling and reinstalling nokogiri using bundle, and specifying the exact path to the libxml2 files that Homebrew installed when

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