Skip to content

select_nodes #569

Answered by zeux
jtaylorme asked this question in Q&A
Jun 11, 2023 · 2 comments
Discussion options

You must be logged in to vote

This works for me as expected:

#include "pugixml.hpp"
#include <stdio.h>

int main(int argc, char **argv)
{
   pugi::xml_document doc;
   doc.load_string("<CATALOG><CD>1</CD><CD>2</CD></CATALOG>");

   pugi::xml_node catalog = doc.select_node("/CATALOG").node();

   for (pugi::xpath_node cd : catalog.select_nodes("CD"))
   {
           printf("CD text %s\n", cd.node().text().get());
   }

   return 0;
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jtaylorme
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants