- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个简单的 libxml2 示例,但它返回以下错误:
$ 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
我在 Lubuntu 11.10 x86_64 上,我有我需要的所有包(我想):libxml2、libxml2-dev、libxml2-dbg...这是示例代码:
// gcc -Wall -lxml2 -I/usr/include/libxml2 -o ex1 ex1.c
#include <stdio.h>
#include <string.h>
#include <libxml/parser.h>
int main(int argc, char **argv)
{
xmlDoc *document;
xmlNode *root, *first_child, *node;
char *filename;
if (argc < 2)
{
fprintf(stderr, "Usage: %s filename.xml\n", argv[0]);
return 1;
}
filename = argv[1];
document = xmlReadFile(filename, NULL, 0);
root = xmlDocGetRootElement(document);
fprintf(stdout, "Root is <%s> (%i)\n", root->name, root->type);
first_child = root->children;
for (node = first_child; node; node = node->next)
{
fprintf(stdout, "\t Child is <%s> (%i)\n", node->name, node->type);
}
fprintf(stdout, "...\n");
return 0;
}
最佳答案
关于c - 链接 libxml2 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7815791/
我已经下载了草莓 PERL 并在 Winxp sp3 上使用 CGI Perl Apache 编写了一个应用程序。我使用的库之一(由其他人编写)使用 XML::LibXML。当我加载页面时,它给出内部
libxml 在 libxml.h 中使用以下代码行,但它不与 libxml 捆绑在一起。 #include "config.h" 我正在尝试在 Swift 中使用 XMPPFramework for
我知道这个问题经常出现,但我查看了所有其他答案,但没有一个与我相关。 我正在尝试从源代码编译神经成像软件 FSL(我必须这样做,我的 Linux 发行版不支持它)。我已按照所有说明进行操作 liste
当我运行 cyrus-imapd-2.4.17-caldav-beta9 时出现以下错误: In file included from httpd.c:68:0: httpd.h:48:25: fat
我熟悉 XML,已经将它用于一些简单的用途。但是,我被要求创建一个自定义解决方案(必须使用 Perl)来向 AuthorizeNet 的网关提交付款。 AuthNet 不提供对 Perl 的支持,所以
我有一个示例 Perl 脚本,我试图根据模式加载和验证文件,它们询问各种节点。 #!/usr/bin/env perl use strict; use warnings; use XML::LibXM
我有我正在迭代的非常大的 XML 文档。 XML 主要使用属性而不是节点值。我可能需要在文件中找到许多节点来拼凑一组信息。它们通过不同的 ref 标签值联系在一起。目前,每次我需要定位其中一个节点以从
我正在使用 XML::LibXML,我想添加一条注释,使注释位于标签之外。甚至可以把它放在标签外面吗?我试过 appendChild,insertBefore |之后,没有区别... jun
我正在使用 XML::LibXML,我想添加一条注释,使注释位于标签之外。甚至可以把它放在标签外面吗?我试过 appendChild,insertBefore |之后,没有区别... jun
我正在尝试使用 ISO-8859-1 中的 libxml2 编写 XML 文件。但从文档看来,对于我创建的每个文本节点,我都必须转换为 UTF-8,这是 libxml 的内部编码。然后,当调用 xml
我正在尝试用 C++ 解析 XML 文档。我没有与文档关联的任何形式的元数据。由于我是 XML 的新手,所以我想了解解析此 xml 的最佳方法。我正在使用 libxml2 来实现这一点。 我目前正在做
使用 libxml2 两天后我就遇到了一个问题,这让我很烦。 基本上,我使用套接字通过网络发送一个 xml 缓冲区。当我在服务器上收到它并尝试解析它时,它说: parser error : Input
我正在使用 libxml 的 HTML 解析器来创建 html 文档的 dom 树。 libxml 将每个节点的文本内容作为一个整体字符串(节点)给出,但我的要求是进一步拆分每个文本节点的空格并创建尽
我已经开始在 C 中使用 libxml,并且正在使用 xmlXPathEvalExpression 函数来计算 XPath。 我的 XML 文件实际上代表一个表,每个子节点代表该表中的一行,其属性是对
我有一个可以通过终端运行的源文件 gcc source.c -I/usr/include/libxml2 -lxml2 -o output 但是当我 #include 包含 libxml 源文件的源文
这里似乎有些奇怪。 在下面的示例中,我通过 XPath 查询 ( //book/isbn/text() ) 访问文本节点。 text()有必要强制XML::LibXML允许我使用 XML::LibXM
我有一个 XML 文件,如下 示例.xml test 以下代码未找到 id 标记值: use XML::LibXML; my $filename = 'example.xml'; my
我正在与 XML::LibXML 一起工作在 Perl 中。 假设我有两个 $element由不同(不透明)XPath 查询获得的引用。 (如何)我可以确定,如果两个$element (节点)refs
我有一个问题,我肯定可以使用一些帮助。首先,要温柔。我是 perl 和 LibXML 的新手。我一直在解析文档并将元素放入一个数组中,然后将其写入电子表格列。在测试过程中发现一些节点有多个同名的子节点
在我的一生中,我无法找出正确的代码来访问我的 XML 文件中的注释行。我是否使用 findnodes , find , getElementByTagName (怀疑)。 我是否正确假设这些评论行是可
我是一名优秀的程序员,十分优秀!