TinyXML - 带有多级元素文件的GetText()

时间:2018-04-26 10:24:52

标签: c++ xml tinyxml2

我有一个XML文件,我需要从中提取数据。我使用tinyxml2。我试图获取文件中元素的文本。文件中的数据如下所示:

<Tasks>

<!-- \GoogleUpdateTaskMachineCore -->
<?xml version="1.0" encoding="UTF-16"?>

<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">

  <RegistrationInfo>

    <Version>1.3.33.7</Version>

    <Description>Keeps your Google software up to date. If this task is disabled or stopped, your Google software will not be kept up to date, meaning security vulnerabilities that may arise cannot be fixed and features may not work. This task uninstalls itself when there is no Google software using it.</Description>

  </RegistrationInfo>

  <Actions Context="Author">

    <Exec>

      <Command>C:\Program Files (x86)\Google\Update\GoogleUpdate.exe</Command>

      <Arguments>/c</Arguments>

    </Exec>

  </Actions>

</Task>

</Tasks>

我尝试使用以下代码提取Description,但它不起作用。

tinyxml2::XMLDocument xmlDoc;
xmlDoc.LoadFile("raw");

XMLNode *pLoadTask = xmlDoc.FirstChild();
XMLElement * pTask = pLoadTask->FirstChildElement("Task")->FirstChildElement("RegistrationInfo")->FirstChildElement("Description");

我做错了什么?

0 个答案:

没有答案