pugixml读写 遍历节点方法

// test.cpp : Defines the entry point for the console application.

//test.xml
/*




Harry Potter
29.99
test_1
test_2


Learning XML
39.95



*/
#include "stdafx.h"
#include 
#include "pugixml.hpp"


int _tmain(int argc, _TCHAR* argv[])
{
	pugi::xml_document doc;
	if (!doc.load_file("test.xml")) return -1;

	pugi::xpath_node_set tools = doc.select_nodes("/bookstore/book[@name='0']"); //筛选出所有 name=0的book节点

	std::cout <node();
		//book 节点名和值
		std::cout<< nodeTmp.name()<<" -- "< child = nodeTmp.children();

		// book/title  book/price  ....等子节点 
	    pugi::xml_node_iterator iterchild = child.begin();
		for (iterchild; iterchild != child.end(); iterchild++)
		{
			
			std::cout<< iterchild->name()<<" -- "<text().as_string()<

 

你可能感兴趣的:(xml解析类)