使用pugiXML提取文本标记中的段落
extracting paragraph in text tag using pugiXML
我在Xcode中使用pugiXML,并试图获得嵌入文本标记中的段落。我使用的语言是C++。我不认为这是重复的,因为我找到了Visual Studio的答案,但没有找到Xcode的答案,其他问题涉及单行提取,而不是整个段落。
我显示的代码正确地检索了标题和ID,但无法提取文本。文本采用段落的形式,两侧有适当的文本标记。我的代码如下:
//open file
if (!doc.load_file("Sample.xml")){
cout << "Couldn't open file" << endl;
}
else{
xml_node page = doc.child("page");
//Correctly getting title and ID
cout << page.child_value("title") << endl;
cout << page.child_value("id") << endl;
//Problem line: can't get text.
cout << page.child_value("text") << endl;
}
我想明白了。我没有进入正确的节点。
这就是我应该做的:
xml_node text = doc.child("page").child("revision").child("text");
cout << text.child_value() << endl;
问题是我使用的方法。
相关文章:
- 如何在pugixml中获取节点的内部XML
- 如何将字符传递到find_child_by_attribute中以获取 pugixml
- 使用 pugixml 将 xml 命名空间添加到xml_document
- Sk段落不塑造或呈现文本
- 在Word中重复段落
- wchar 模式下 pugixml 的链接错误
- 根据 Pugixml 中的子值删除节点
- 如何使用 pugixml 正确访问 xml 属性?
- 计算段落中出现次数最多的单词
- C++关于非专用模板的成员模板专业化的标准段落
- C 标准中的哪个段落验证了以下示例中使用的表达式`sizeof(s :: m 42)`
- 从一个段落到另一个段落,从一行到另一行阅读单词(C++)
- 关于模板参数推理的看似有缺陷的段落?
- CMake and pugixml
- 如果两个静态库包含 pugixml objs,如何避免与 pugixml 的“已定义”链接错误
- 将变量传递给 PUGIXML xml_tree_walker
- 通过Pugixml C 提取XML文件中的节点的所有节点
- 元素 std::vector <struct>的更有成效的段落
- 从父节点中删除子节点 - PugiXML
- 使用pugiXML提取文本标记中的段落