当前位置: 首页>>代码示例>>C++>>正文


C++ XmlElement::getChildren方法代码示例

本文整理汇总了C++中XmlElement::getChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlElement::getChildren方法的具体用法?C++ XmlElement::getChildren怎么用?C++ XmlElement::getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlElement的用法示例。


在下文中一共展示了XmlElement::getChildren方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

static void
storeNode( const XmlNode* node, int depth, std::ostream& out )
{
    out << std::fixed; // always use fixed notation

    for( int k=0; k<depth*INDENT; k++ ) out << " ";

    if ( node->isElement() )
    {
        XmlElement* e = (XmlElement*)node;
        out << "<" << e->getName();
        for( XmlAttributes::iterator a = e->getAttrs().begin(); a != e->getAttrs().end(); a++ )
        {
            out << " " << a->first << "=" << "\"" << a->second << "\"";
        }
        out << ">" << std::endl;
        for( XmlNodeList::iterator i = e->getChildren().begin(); i != e->getChildren().end(); i++ )
        {
            storeNode( i->get(), depth+1, out );
        }
        for( int k=0; k<depth*INDENT; k++ ) out << " ";
        out << "</" << e->getName() << ">" << std::endl;
    }
    else if ( node->isText() )
    {
        XmlText* t = (XmlText*)node;
        const std::string& text = t->getValue();
        if ( text.find_first_of( "<&" ) != std::string::npos )
            out << "<![CDATA[" << text << "]]>" << std::endl;
        else
            out << text << std::endl;
    }
}
开发者ID:jehc,项目名称:osgearth,代码行数:33,代码来源:XmlUtils.cpp

示例2: if

static void
storeNode( const XmlNode* node, TiXmlNode* parent)
{
    if (node->isElement())
    {
        XmlElement* e = (XmlElement*)node;
        TiXmlElement* element = new TiXmlElement( e->getName().c_str() );
        //Write out all the attributes
        for( XmlAttributes::iterator a = e->getAttrs().begin(); a != e->getAttrs().end(); a++ )
        {
            element->SetAttribute(a->first.c_str(), a->second.c_str() );            
        }

        //Write out all the child nodes
        for( XmlNodeList::iterator i = e->getChildren().begin(); i != e->getChildren().end(); i++ )
        {
            storeNode( i->get(), element );
        }
        parent->LinkEndChild( element );
    }
    else if (node->isText())
    {
        XmlText* t = (XmlText*)node;
        parent->LinkEndChild( new TiXmlText( t->getValue().c_str() ) );
    }
}
开发者ID:JohnDr,项目名称:osgearth,代码行数:26,代码来源:XmlUtils.cpp

示例3: XmlElement

void
XmlElement::addSubElement(const std::string& tag, const std::string& text)
{
    XmlElement* ele = new XmlElement(tag);
    ele->getChildren().push_back(new XmlText(text));
    children.push_back(ele);
}
开发者ID:JohnDr,项目名称:osgearth,代码行数:7,代码来源:XmlUtils.cpp

示例4: data

static void XMLCALL
handleCharData( void* user_data, const XML_Char* c_data, int len )
{
    if ( len > 0 )
    {
        XmlElementNoRefStack& stack = *(XmlElementNoRefStack*)user_data;
        XmlElement* top = stack.top();
        std::string data( c_data, len );
        top->getChildren().push_back( new XmlText( data ) );
    }
}
开发者ID:aarnchng,项目名称:osggis,代码行数:11,代码来源:XmlDocument.cpp

示例5: tag

static void XMLCALL
startElement( void* user_data, const XML_Char* c_tag, const XML_Char** c_attrs )
{
    XmlElementNoRefStack& stack = *(XmlElementNoRefStack*)user_data;
    XmlElement* top = stack.top();

    std::string tag( c_tag );
    std::transform( tag.begin(), tag.end(), tag.begin(), tolower );
    XmlAttributes attrs = getAttributes( c_attrs );

    XmlElement* new_element = new XmlElement( tag, attrs );
    top->getChildren().push_back( new_element );
    stack.push( new_element );
}
开发者ID:aarnchng,项目名称:osggis,代码行数:14,代码来源:XmlDocument.cpp

示例6: if

static void
storeNode( XmlNode* node, int depth, std::ostream& out )
{
    for( int k=0; k<depth*INDENT; k++ )
        out << " ";

    if ( node->isElement() )
    {
        XmlElement* e = (XmlElement*)node;
        out << "<" << e->getName();
        for( XmlAttributes::iterator a = e->getAttrs().begin(); a != e->getAttrs().end(); a++ )
        {
            out << " " << a->first << "=" << "\"" << a->second << "\"";
        }
        if ( e->getChildren().empty())
        {
        	out << "/>" << std::endl;
        }
        else
        {
        	out << ">" << std::endl;
			for( XmlNodeList::iterator i = e->getChildren().begin(); i != e->getChildren().end(); i++ )
			{
				storeNode( i->get(), depth+1, out );
			}
		    for( int k=0; k<depth*INDENT; k++ )
		        out << " ";
			out << "</" << e->getName() << ">" << std::endl;
        }

    }
    else if ( node->isText() )
    {
        XmlText* t = (XmlText*)node;
        out << t->getValue() << std::endl;
    }
}
开发者ID:aarnchng,项目名称:osggis,代码行数:37,代码来源:XmlDocument.cpp


注:本文中的XmlElement::getChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。