libxml ++ C ++按名称查找节点

时间:2012-11-13 16:25:18

标签: c++ xml libxml2

我使用libxml ++从wikimedia解析xml文件。我已经能够使用textparser将文本从所有节点推送到堆栈,但我想在页面和/页面之间专门获取文本以及获取文本,作者姓名和标题。我对使用libxml ++如何做到这一点感到茫然。以下是维基媒体页面的示例

<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.7/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.7/ http://www.mediawiki.org/xml/export-0.7.xsd" version="0.7" xml:lang="en">
  <page>
    <title>Human Anatomy/Osteology/Axialskeleton</title>
    <ns>0</ns>
    <id>181313</id>
    <revision>
      <id>1481605</id>
  <parentid>1379871</parentid>
  <timestamp>2009-04-26T02:03:12Z</timestamp>
  <contributor>
    <username>Adrignola</username>
    <id>169232</id>
  </contributor>
  <minor/>
  <comment>+Category</comment>
  <sha1>hvxozde19haz4yhwj73ez82tf2bocbz</sha1>
  <text xml:space="preserve">[[Image:Axial_skeleton_diagram.svg|thumb|240px|right|Diagram of the axial skeleton]]

The Axial Skeleton is a division of the human skeleton and is named because it makes up the longitudinal ''axis'' of the body. It consists of the skull, hyoid bone, vertebral column, sternum and ribs. It is widely accepted to be made up of 80 bones, although this number varies from individual to individual.

[[Category:{{FULLBOOKNAME}}|{{FULLCHAPTERNAME}}]]</text>
</revision>

如何将文本,作者,日期等节点保存为字符串或Glib :: ustrings?我尝试使用xpath来利用。 谢谢你的帮助,这不是功课。

-gtk

0 个答案:

没有答案