コード例 #1
0
ファイル: DomTree.cpp プロジェクト: pcontezini/pdom
void DomTree::dumpTree() const {
	std::cout << "root: " << name << " encoding: " << encoding << " version: " << version << std::endl;
	std::cout << "---------------------------------------------------" << std::endl;
	for(unsigned int i = 0; i < elements.size() ; i++) {
		int entrylevel = 0;
		DomElement *ptr = elements[i];
		std::cout << "element: " << ptr->getName() << " value: " << ptr->getValue() << std::endl;
		if ( ptr->getChildren().size() > 0 ) {
			for(unsigned int a = 0; a < ptr->getChildren().size() ; a++) {
				dumpChildren(ptr->getChildren()[a],entrylevel);
			}
		}
		for(unsigned int c = 0; c < ptr->getAttributes().size() ; c++ ) {
			DomAttribute *aptr = ptr->getAttributes()[c];
			std::cout << "attribute: " << aptr->getName() << " value: " << aptr->getValue() << std::endl;
		}
		std::cout << "---------------------------------------------" << std::endl;
	}
}
コード例 #2
0
ファイル: LuaXml2.cpp プロジェクト: Wushaowei001/NAF
int LuaDomElement2::getAttributes(lua_State *L)
{
	DomElement* obj = DomElementValue::check2( L, 1 );
	const DomElement::Atts& n = obj->getAttributes();
	lua_newtable( L );
	int t = lua_gettop( L );
	DomElement::Atts::const_iterator i;
	for( i = n.begin(); i != n.end(); ++i )
	{
		lua_pushstring( L, i.key() );
		lua_pushstring( L, i.value().data() );
		lua_rawset( L, t );
	}
	return 1;
}