libxml2

PHP LIBXML_NOWARNING not suppressing warnings?

浪尽此生 提交于 2020-01-29 13:23:28
问题 Using the LIBXML_NOWARNING options flag doesn't stop wanrings when loading html with PHPDOMDocument->loadHTML. Other constants do work though. In the example below I add the LIBXML_HTML_NODEFDTD to prove that the constants are received(stops a doctype from being added). $doc=new DOMDocument(); $doc->loadHTML("<tagthatdoesnotexist><h1>Hi</h1></tagthatdoesnotexist>",LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_HTML_NODEFDTD); echo $doc->saveHTML(); However, warnings are still generated and output

linux安装php & nginx

我怕爱的太早我们不能终老 提交于 2020-01-29 10:58:44
1.安装libxml2 地址: http://ftp.gnome.org/pub/GNOME/sources/libxml2/ wget http://caesar.acc.umu.se/pub/GNOME/sources/libxml2/2.6/libxml2-2.6.30.tar.gz ./configure --prefix=/usr/local/libxml2 make make install 失败的话执行 make clean,再重复上述操作 2.安装php -下载php ... ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2 make make install 也可以使用yum安装软件包: yum list | grep xxx yum install -y libpng-devel libjpeg-devel freetype-devel libmcrypt-devel ... ./configure --prefix=/usr/local/php5.6 --with-config-file-path=/usr/local/php5.6/etc --enable-fpm --with-libxml-dir=

how to write a CDATA node using libxml2?

本小妞迷上赌 提交于 2020-01-24 20:23:06
问题 I'm using libxml2 to read/write xml files. Now I'm trying to write a CDATA node. Here is what I tried: nodePtr = xmlNewChild( parentPtr, NULL, "foo", NULL ); xmlNodeSetContentLen( nodePtr, "<![CDATA[\nTesting 1 < 2\n]]>", len ); However, this results in the following encoded text: <foo><![CDATA[ Testing 1 < 2 ]]></foo> I'm thinking that perhaps there might be a CDATA-specific libxml2 API. Or maybe I have to call something else to tell libxml2 not to automatically encode the node content? 回答1:

libxml2 fails on xsd schema validation for element type anyURI containing special characters like “[”, “[”

纵然是瞬间 提交于 2020-01-24 17:51:29
问题 I am using go-libxml2 for my xsd schema validation. I have an XML element which takes url as a value. My xsd also contains its type as anyURI as follows <xs:element name="url" type="xs:anyURI"> The following code throws error on validation url which contains "[]" xsd.schema.Validate(xml) The following is the sample url which throws an error <url> <![CDATA[ http://example.com/orda/var[div]=super ]]> </url> Error: 'http://example.com/orda/var[div]=super is not a valid value of the atomic type

Validate XPath expression

浪子不回头ぞ 提交于 2020-01-15 09:41:37
问题 I would like to validate a user-provided XPath query to ensure that it is syntactically correct. Does it make sense to "validate" an XPath query without an XML document? How can i achieve such a thing in libxml? 回答1: You can compile an XPath expression using libxml without evaluating it. See xmlXPathCompile. The return value should be NULL for invalid expressions. #include <stdio.h> #include <libxml/xpath.h> #include <libxml/xmlerror.h> void handle_structured_error(void *userdata, xmlErrorPtr

Validate XPath expression

非 Y 不嫁゛ 提交于 2020-01-15 09:40:58
问题 I would like to validate a user-provided XPath query to ensure that it is syntactically correct. Does it make sense to "validate" an XPath query without an XML document? How can i achieve such a thing in libxml? 回答1: You can compile an XPath expression using libxml without evaluating it. See xmlXPathCompile. The return value should be NULL for invalid expressions. #include <stdio.h> #include <libxml/xpath.h> #include <libxml/xmlerror.h> void handle_structured_error(void *userdata, xmlErrorPtr

How to restrict an XPath via xmlXPathNodeEval() to a subtree?

好久不见. 提交于 2020-01-15 06:13:03
问题 To evaluate an XPath expression only inside a certain subtree the libxml2 function xmlXPathNodeEval() seems to be the way to go. The documentation specifies that the XPath expression is evaluated 'in the given context'. But what does this exactly mean? Consider following small example: #include <libxml/tree.h> #include <libxml/xpath.h> #include <libxml/xmlstring.h> #include <stdio.h> int main(int argc, char **argv) { const char inp[] = "<root>\n" " <sub>\n" " <e>0</e>\n" " <Foo>\n" " <e>1</e>

How to restrict an XPath via xmlXPathNodeEval() to a subtree?

六眼飞鱼酱① 提交于 2020-01-15 06:12:44
问题 To evaluate an XPath expression only inside a certain subtree the libxml2 function xmlXPathNodeEval() seems to be the way to go. The documentation specifies that the XPath expression is evaluated 'in the given context'. But what does this exactly mean? Consider following small example: #include <libxml/tree.h> #include <libxml/xpath.h> #include <libxml/xmlstring.h> #include <stdio.h> int main(int argc, char **argv) { const char inp[] = "<root>\n" " <sub>\n" " <e>0</e>\n" " <Foo>\n" " <e>1</e>

cannot Install libxml2 in virtualenv

泄露秘密 提交于 2020-01-14 12:02:02
问题 I have got an issue with libxml2 python module. I'm trying to install it on a python3 virtualenv using the following command: pip install libxml2-python3 but it shows the following error: Collecting libxml2-python3 Using cached https://files.pythonhosted.org/packages/41/97/a2ecf6c5b291799dbd40b3d041d89b0ecdb1b43c8c2503e27991325851cd/libxml2-python3-2.9.5.tar.gz Complete output from command python setup.py egg_info: failed to find headers for libxml2: update includes_dir ----------------------

Handling Surrogate pairs while parsing xml using libxml2

坚强是说给别人听的谎言 提交于 2020-01-14 06:22:12
问题 I am trying to parse xml using libxml2. However, sometimes I get code points of surrogate pairs in it which are outside the range specified in http://www.w3.org/TR/REC-xml/#NT-Char Because of this, my libxml2 parser is not able to parse it and thus I get error. Can somebody tell me how to handle surrogate pairs while parsing XML using libxml2. An example xml I want to parse is: <?xml version="1.0" encoding="UTF-8"?> <message><body> &#xD83D;&#xD83D;</body></message> 回答1: Note that xD83D is a