pugixml例子

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>  
<Profile FormatVersion="1">  
    <Tools>  
        <Tool Filename="jam" AllowIntercept="true">  
            <Description>Jamplus build system</Description>  
        </Tool>  
        <Tool Filename="mayabatch.exe" AllowRemote="true" OutputFileMasks="*.dae" DeriveCaptionFrom="lastparam" Timeout="40" />  
        <Tool Filename="meshbuilder_*.exe" AllowRemote="false" OutputFileMasks="*.mesh" DeriveCaptionFrom="lastparam" Timeout="10" />  
        <Tool Filename="texbuilder_*.exe" AllowRemote="true" OutputFileMasks="*.tex" DeriveCaptionFrom="lastparam" />  
        <Tool Filename="shaderbuilder_*.exe" AllowRemote="true" DeriveCaptionFrom="lastparam" />  
    </Tools>  
</Profile>  

使用pugixml简单几句代码就能将所有Tool节点的属性值都输出来:

pugi::xml_document doc;  
    if (!doc.load_file("xgconsole.xml")) return -1;  

    pugi::xml_node tools = doc.child("Profile").child("Tools");  

    //[code_traverse_base_basic  
    for (pugi::xml_node tool = tools.first_child(); tool; tool = tool.next_sibling())  
    {  
        std::cout << "Tool:";  

        for (pugi::xml_attribute attr = tool.first_attribute(); attr; attr = attr.next_attribute())  
        {  
            std::cout << " " << attr.name() << "=" << attr.value();  
        }  

        std::cout << std::endl;  
    }  
//]  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值