问题标签 [pugixml]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
355 浏览

c++ - pugixml,根据其他孩子的值选择特定的孩子

我将 pugixml 与 C++ 一起使用,效果很好。但是,我希望能够从这样的结构中选择一个特定的孩子:

如果我想获得 +0200 的值,那么能够执行以下操作会很好:

我查看了 find_child_by_attribute,但它似乎不符合目的。

0 投票
4 回答
3489 浏览

c++ - Pugixml C++ 解析 XML

我是 pugixml 的新手。考虑我在这里给出了 XML 。我想获得Name每个Roll学生的价值。下面的代码只找到标签而不是值。

我想要每个学生的姓名和名册的输出。如何修改上面的代码?另外,如果可以参考这里(按测试),我可以直接编写 pugixml 支持的 xpath。如果是这样,我怎样才能获得我在 Pugixml 中使用 Xpath 寻求的值。

0 投票
2 回答
344 浏览

c++ - 如何从函数返回对象变量?

某些变量中的值正在重叠。
当我第一次在节点上循环时,一切正常,但是当我再次循环时,会打印最后一个创建的变量的值,有时程序会停止工作。

这就是我从不同文件中获取节点的方式:

xml 是这样的:

错误:practice.exe 中 0x00eb0cdd 处的未处理异常:0xC0000005:访问冲突读取位置 0xfeeeff0a。
main.exe 已停止工作并将我指向此功能:

当我将函数中的代码添加到 main.cpp 时,变量值打印完美(我认为我从 getNodesXML() 返回值的方式有问题)

0 投票
0 回答
557 浏览

pugixml - Pugixml 节点行号

是否可以从 pugixml 中的 xml_node 获取行号?

例如

它应该为“测试”返回“3”。

0 投票
0 回答
74 浏览

c++ - C++ - PugiXML 和 SIGSEGV

我需要在我的 C++ 程序中解析 XML。所以我昨天决定使用 PugiXML 库。问题是,当我尝试使用该库中的任何内容时,每次都会收到 SIGSEGV 错误。最令人困惑的是,程序在getMessage()与 PugiXML 库没有任何共同之处的方法中中止。

你看出来了,问题出在哪里?


CPP代码


生成文件


项目目录结构

0 投票
1 回答
48 浏览

c++ - 比较时返回节点信息

我在编写这段代码时得到了一些帮助。目前,代码所做的是打印出文件中差异的 id 编号,即新的与旧的相比,添加、删除或保持不变。

但是我想要做的是返回节点中的信息,当它只出现在 new.xml 中时,而不仅仅是 ID(即标题、位置、日期)。

我可以从谷歌找到的最好的猜测是使用(不知道如何实现):xpath->getAncestor

我当前的代码

这是一个示例 XML:

我将获得数十万个总结果和数万个添加条目,因此我正在寻找实现这一目标的最有效方法。

0 投票
1 回答
223 浏览

c++ - 使用 pugixml 为不同的输入映射节点名称

问题

我的程序使用pugixml从文件中吐出 XML 节点。这是执行此操作的代码位:

吐出的所有节点都应具有以下格式(例如 filea.xml):

然而,吐出的内容取决于输入数据的格式。有时标签被称为不同的东西,我最终可能会这样(例如 fileb.xml):

可能的解决方案

是否可以定义非标准映射(节点名称),以便无论输入文件上的节点名称是什么,我总是 std:cout 以相同的格式(iddescription

似乎答案基于以下代码:

我是 C++ 新手,因此对如何实现这一点的任何建议将不胜感激。我必须在数以万计的字段上运行它,所以性能是关键。

参考

https://pugixml.googlecode.com/svn/tags/latest/docs/manual/modify.html https://pugixml.googlecode.com/svn/tags/latest/docs/samples/modify_base.cpp

0 投票
1 回答
292 浏览

c++ - 使用 pugiXML 根据 std::map 重命名节点

我是 C++ 新手,但我正在尝试定义一组标准的节点名称,然后映射到它们。

例如我的标准导入/输出模式是这样的:

但是,有时我的 XML 导入会被命名为不同的名称,因此我想创建一个映射,以便它仍然以上述格式输出,即使输入文件具有以下命名约定:

根据我所获得的文档和帮助,这段代码是我最好的猜测,但我一直在努力完成它:

理想情况下,此代码将允许以任何一种方式格式化 xml,但始终输出相同。任何帮助将非常感激。上面的代码给了我以下错误:

0 投票
1 回答
183 浏览

c++ - Loop through map on returned XML to get node value

In my C++ program I spit out nodes from an XML file. I have a standard schema which may not be followed by the input file. I therefore need to map a node title with the information type which is contained within it.

The information I am particualy asking for help with is within for (auto& eb: mapb) {. Here I am trying to look at the XML recevied and see if I can match the tags to names in the map (i.e content and web_address) and if so, print the value of the node, associating it to what is it (i.e description or url).

I haven't been able to test this because of this compilation error, which I don't understand because I have refered to node above:

g++ -g -Wall -std=c++11 -I include -o main src/main.cpp include/pugi/pugixml.cpp src/main.cpp:51:38: error: use of undeclared identifier 'node' std::cout << "which has value" << node.child_value(kv.second)

My expected output is this:

  • Found description which has this value Hello!
  • Found url which has this value www.hotmail.com

From this input

0 投票
2 回答
838 浏览

c++ - 具有相对路径的 Pugi XML

如何让 pugi XML 找到具有相对路径的文件。

我的文件夹看起来像这样

XML 文件位于此处

XMLConfiguration->_master_config.xml

配置->src

我把代码放在这里

当我运行代码时,我得到了这个: