Poseidon Security
Poseidon Security

Reputation: 1

Get Comment in XML file by RapidXML

I try to get value of a command in xml file. I found the function type() on its manual. But it just return numberic value about type of node. Are there any ways to get it?

This is my snippet:

 xml_node<> *Node = Doc.first_node();
 xml_node<> *Sub = Node->first_node("Task");
std::cout << "Comment: " << Sub->type() << std::endl;

And the value return is: Comment: 1

This is file's content:

<!-- \GoogleUpdateTaskMachineCore -->    ***<<== this is the value I wanna get.***
<?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>

  <Triggers>

    <LogonTrigger>

      <Enabled>true</Enabled>

    </LogonTrigger>

    <CalendarTrigger>

      <StartBoundary>2017-11-14T12:07:01</StartBoundary>

      <ScheduleByDay>

        <DaysInterval>1</DaysInterval>

      </ScheduleByDay>

    </CalendarTrigger>

  </Triggers>

  <Principals>

    <Principal id="Author">

      <UserId>S-1-5-18</UserId>

      <RunLevel>HighestAvailable</RunLevel>

    </Principal>

  </Principals>

  <Settings>

    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>

    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>

    <StartWhenAvailable>true</StartWhenAvailable>

    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>

    <Enabled>true</Enabled>

    <RunOnlyIfIdle>false</RunOnlyIfIdle>

    <WakeToRun>false</WakeToRun>

    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>

  </Settings>

  <Actions Context="Author">

    <Exec>

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

      <Arguments>/c</Arguments>

    </Exec>

  </Actions>

</Task>

Upvotes: 0

Views: 276

Answers (1)

Roddy
Roddy

Reputation: 68033

First, you'll need need to use the parse_comment_nodes flag when you parse() the document.

Then, iterate through the nodes until you find a node with type() == node_comment, then get the value() of that node.

Upvotes: 1

Related Questions