TinyXML - GetText () с многоуровневым элементом - PullRequest
0 голосов
/ 26 апреля 2018

У меня есть 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");

Что я делаю не так?

...