我试图安装Nokogiri但我总是得到一个编译错误:
checking for libxml/parser.h... *** extconf.rb failed ***
Run Code Online (Sandbox Code Playgroud)
但是,我已经安装了它和所有其他依赖项.
我尝试给安装程序提示如下:
%> gem install nokogiri -- --with-xml2-lib=/usr/lib/ --with-xml2-include=/usr/include/libxml2/
...
checking for libxml/parser.h... *** extconf.rb failed ***
...
Run Code Online (Sandbox Code Playgroud)
但它仍然没有安装:
%> find /usr/include/ -name "parser.h"
/usr/include/libxml2/libxml/parser.h
...
Run Code Online (Sandbox Code Playgroud)
我在Ubuntu 11.10上.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
产量:
" dpkg-query -l | grep xml"和" dpkg-query -l | grep xslt"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
失败似乎是海湾合作委员会的一方:
%> cat hello.c
#include <stdio.h>
main()
{
printf("Hello World \n");
}
%> gcc hello.c
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x12): undefined reference to `__libc_csu_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crt1.o: In …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用xmllint来检查我的工作,同时开发一个基本的XSD即XML Schema架构.但它给了我一个错误
验证失败:未找到DTD.
我究竟做错了什么?
我的xmllint命令:
xmllint --noout --valid --schema simple.xsd lucas-basic.xml
lucas-basic.xml:5: validity error : Validation failed: no DTD found !
>
^
lucas-basic.xml validates
Run Code Online (Sandbox Code Playgroud)
测试XSD文件:
<?xml version = "1.0" encoding = "UTF-8"?>
<!--Generated by XML Authority. Conforms to w3c http://www.w3.org/2001/XMLSchema-->
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
<xsd:element name = "vehicles">
<xsd:complexType>
<xsd:sequence>
<xsd:element name = "nickname" type = "xsd:string" maxOccurs = "unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Run Code Online (Sandbox Code Playgroud)
测试XML文件:
<?xml version="1.0"?>
<vehicles
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation = "http://lucas.ucs.ed.ac.uk/xml-schema/xmlns/simple.xsd"
>
<nickname>Bog Hopper</nickname>
<nickname>Wee Beastie</nickname>
<nickname>Count …Run Code Online (Sandbox Code Playgroud) 我试图看看libxml如何实现XPath支持,所以我使用xmllint进行测试是有意义的.但是,显而易见的选项--pattern,有点模糊,我最终使用了类似下面的内容:
test.xml: <foo><bar/><bar/></foo>
> xmllint --shell test.xml
/ > dir /foo
ELEMENT foo
/ > dir /foo/*
ELEMENT bar
ELEMENT bar
Run Code Online (Sandbox Code Playgroud)
这似乎有效,这很好,但我仍然很好奇.什么是xmllint的--pattern选项,以及它是如何工作的?
提供完整信用的示例.=)
我目前在我的iPhone项目中遇到了一些libxml2错误.在我的构建属性构建中进行一些更改失败后,这工作正常.(在构建阶段添加了libxml2.dylib)
#import <libxml/tree.h>
#import <libxml/parser.h>
#import <libxml/xmlstring.h>
#import <libxml/xpath.h>
#import <libxml/xpathInternals.h>
Run Code Online (Sandbox Code Playgroud)
我已将以下项添加到构建设置:
Other Linker Flags: -lxml2
Header Search Paths: /usr/include/libxml2
Run Code Online (Sandbox Code Playgroud)
我已经尝试将它们添加到项目和目标(同时,并在它们之间切换)没有任何区别.
我还尝试将以下内容添加到标题搜索路径:
${SDKROOT}
${SDK_DIR}
Run Code Online (Sandbox Code Playgroud)
两者都没有结果.
建筑失败:iPhone设备iPhone和iPad模拟器
有人有想法吗?
我正在使用GData Objective-C客户端库:http://code.google.com/p/gdata-objectivec-client/ 我正在将源文件直接编译到我的项目中,并按照给出的所有步骤进行操作维基.再次手动导入libxml标头时,XCode会建议以下内容:
#import <libxml2/libxml/tree.h>
Run Code Online (Sandbox Code Playgroud)
哪个也行不通.
我发现搜索类似问题的是Nokogiri还没有使用Ruby 2.0的 x64支持.然而,虽然我在Windows x64机器上,我的Ruby版本是来自railsinstaller.org的ruby 1.9.3p392(2013-02-22)[i386-mingw32](使用Rails 3.2.13).这也意味着已经安装了DevKit.
gem install nokogiri --pre给出了这个错误:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokog
iri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of …Run Code Online (Sandbox Code Playgroud) 我在这里粘贴一些代码,使用gcc file.c -lxml2编译没有警告,假设你的系统中安装了libxml2.
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <assert.h>
#include <libxml/tree.h>
#include <libxml/xpathInternals.h>
xmlDocPtr
getdoc (char *docname) {
xmlDocPtr doc;
doc = xmlParseFile(docname);
if (doc == NULL ) {
fprintf(stderr,"Document not parsed successfully. \n");
return NULL;
}
return doc;
}
xmlXPathObjectPtr
getnodeset (xmlDocPtr doc, xmlChar *xpath){
xmlXPathContextPtr context;
xmlXPathObjectPtr result;
context = xmlXPathNewContext(doc);
if (context == NULL) {
printf("Error in xmlXPathNewContext\n");
return NULL;
}
if(xmlXPathRegisterNs(context, BAD_CAST "new", BAD_CAST "http://www.example.com/new") != 0) {
fprintf(stderr,"Error: unable to register NS with prefix");
return …Run Code Online (Sandbox Code Playgroud) 如果我通过xmllint运行此XML验证:
xmllint --noout --schema schema.xsd test.xml
Run Code Online (Sandbox Code Playgroud)
我收到了这条成功的消息:
.../test.xml validates
Run Code Online (Sandbox Code Playgroud)
但是,如果我通过libxml2的C API运行相同的验证:
int result = xmlSchemaValidateDoc(...)
Run Code Online (Sandbox Code Playgroud)
我得到一个返回值1845和此失败消息:
Element '{http://example.com/XMLSchema/1.0}foo': No matching global declaration available for the validation root.
Run Code Online (Sandbox Code Playgroud)
我绝对没有意义.:(
schema.xsd:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd" >
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://example.com/XMLSchema/1.0" targetNamespace="http://example.com/XMLSchema/1.0" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="foo">
</xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
的test.xml:
<?xml version="1.0" encoding="UTF-8"?>
<foo xmlns="http://example.com/XMLSchema/1.0">
</foo>
Run Code Online (Sandbox Code Playgroud)
main.c中:
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h> …Run Code Online (Sandbox Code Playgroud) 我正在试图找出我目前安装的版本.OS X Mountain Lion(10.8.2)
提前致谢!
我正在使用XML::LibXML,我只需要计算XPath表达式指定的节点数.
使用下面前两个代码行中的任何一个产生我正在寻找的东西.我可以使用或不使用countXPath函数(是的,我知道,因为它返回一个列表).findvaluefindfindnodes
my $node_cnt = $dom->findvalue("count($xpath_str)"); # WORKS!
my $node_cnt = $dom->find("count($xpath_str)"); # WORKS!
my @node_cnt = $dom->findnodes("count($xpath_str)"); # count doesn't work!
Run Code Online (Sandbox Code Playgroud)
这引出了一个普遍的唠叨问题:这三种find类型有什么区别?在文档中,它说:
$string = $node->findvalue($xpath)
$result = $node->find($xpath)
@nodes = $node->findnodes($xpath_expression)
Run Code Online (Sandbox Code Playgroud)
论证$xpath_expression与$xpath文档之间是否真的存在差异?
对于返回标量的两个人来说,有什么区别?
我试图理解使用一种查找类型的重要性 - 谢谢!
我正在尝试安装libxml-ruby.我安装了libxml2,libxslt和coreutils
我还阅读了有关该问题的其他帖子,但没有一个解决它.
brew list libxslt
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/bin/xslt-config
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/bin/xsltproc
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/include/libexslt/ (3 files)
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/include/libxslt/ (21 files)
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/lib/libexslt.0.dylib
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/lib/libxslt.1.dylib
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/lib/pkgconfig/ (2 files)
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/lib/ (5 other files)
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/share/aclocal/libxslt.m4
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/share/doc/ (90 files)
/opt/boxen/homebrew/Cellar/libxslt/1.1.28_1/share/man/ (3 files)
Run Code Online (Sandbox Code Playgroud)
brew list libxml2
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/bin/xml2-config
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/bin/xmlcatalog
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/bin/xmllint
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/include/libxml2/ (47 files)
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/lib/libxml2.2.dylib
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/lib/cmake/libxml2/libxml2-config.cmake
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/lib/pkgconfig/libxml-2.0.pc
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/lib/ (3 other files)
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/share/aclocal/libxml.m4
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/share/doc/ (153 files)
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/share/gtk-doc/ (55 files)
/opt/boxen/homebrew/Cellar/libxml2/2.9.4/share/man/ (4 files)
Run Code Online (Sandbox Code Playgroud)
gem install libxml-ruby 产生以下错误:
Building native extensions. This could take a while...
ERROR: Error installing libxml-ruby:
ERROR: Failed …Run Code Online (Sandbox Code Playgroud)