本文整理汇总了C++中XMLElement::FindElementZ方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLElement::FindElementZ方法的具体用法?C++ XMLElement::FindElementZ怎么用?C++ XMLElement::FindElementZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLElement
的用法示例。
在下文中一共展示了XMLElement::FindElementZ方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readFromXML
void Face::readFromXML(XMLElement* parent)
{
XMLElement* fac;
char check_parent[50]={0};
parent->GetParent()->GetElementName(check_parent);
if(parent->FindElementZ("face"))
fac=parent->FindElementZ("face");
else if(string(check_parent)=="FaceSetPart")
fac=parent;
if (fac->FindElementZ("vertex"))
{
int num=fac->FindElementZ("vertex")->GetContentsNum();
if(num)
{
XMLContent** c=fac->FindElementZ("vertex")->GetContents();
string cad;//,type="vertex";
for (int i=0;i<num;i++)
{
cad=string();
cad.resize(c[i]->GetSize());
c[i]->GetValue((char*)cad.c_str());
vector<Vector3D> aux_vec=Vector3D::stringToVectorVector3D(cad);
for (int j=0;j<aux_vec.size();j++)
{
addVertex(aux_vec[j].x,aux_vec[j].y);
}
}
}
}
//if(fac->FindElementZ("Attributes"))
//{
// XMLElement* atrib=fac->FindElementZ("Attributes");
// if(atrib->FindVariableZ("r"))
// r=atrib->FindVariableZ("r")->GetValueFloat();
// if(atrib->FindVariableZ("g"))
// g=atrib->FindVariableZ("g")->GetValueFloat();
// if(atrib->FindVariableZ("b"))
// b=atrib->FindVariableZ("b")->GetValueFloat();
// if(atrib->FindVariableZ("alfa"))
// alfa=atrib->FindVariableZ("alfa")->GetValueFloat();
//}
base.readFromXML(fac);
}
示例2: ProcessImagesLibraryXML
/// process images library
void TSRModelExporterXML::ProcessImagesLibraryXML( XMLElement* _pRootElement )
{
XMLElement* pImagesLibrary = _pRootElement->FindElementZ( "library_images" );
if ( pImagesLibrary )
{
for ( unsigned int i = 0; i < pImagesLibrary->GetChildrenNum(); i++ )
{
XMLElement* pCurrImageElement = pImagesLibrary->GetChildren()[ i ];
if ( pCurrImageElement )
{
m_XMLImages.push_back( pCurrImageElement );
XMLElement* pInitFromElement = pCurrImageElement->FindElementZ( "init_from" );
XMLElement* pRefElement = pInitFromElement->FindElementZ( "ref" );
string strTemp;
if ( pRefElement )
{
strTemp = pRefElement->GetContents()[ 0 ]->c;
TSRModelTexture newTwisterTexture;
memset( &newTwisterTexture, 0, sizeof( TSRModelTexture) ) ;
sscanf( strTemp.c_str(), "%s", newTwisterTexture );
m_TwisterImages.push_back( newTwisterTexture );
}
else
{
strTemp = pInitFromElement->GetContents()[ 0 ]->c;
TSRModelTexture newTwisterTexture;
memset( &newTwisterTexture, 0, sizeof( TSRModelTexture) ) ;
assert( ( strTemp.length() < 64 ) && "Texture filename is too long, consider using relative paths" );
if ( strTemp.length() >= 64 )
{
CookAssetError( "Texture filename is too long, consider using relative paths" );
}
sscanf( strTemp.c_str(), "%s", newTwisterTexture.m_Name );
m_TwisterImages.push_back( newTwisterTexture );
}
}
}
}
ExportModelTextures();
}
示例3: main
int main()
{
OleInitialize(0);
char* f1 = "http://www.turboirc.com/xml/sample1.xml";
char* f2 = ".\\sample2.xml";
XML* x = 0;
// Load from file or url
FILE* fp = fopen(f1,"rb");
if (fp)
{
// Load from file
fclose(fp);
x = new XML(f1);
}
else
{
// Load from url
x = new XML(f1,XML_LOAD_MODE_URL);
}
// Parse status check
int iPS = x->ParseStatus(); // 0 OK , 1 Header warning (not fatal) , 2 Error in parse (fatal)
bool iTT = x->IntegrityTest(); // TRUE OK
if (iPS == 2 || iTT == false)
{
fprintf(stderr,"Error: XML file %s is corrupt (or not a XML file).\r\n\r\n",f1);
delete x;
return 0;
}
// Sample export to stdout
x->Export(stdout,XML_SAVE_MODE_ZERO);
// Sample XML functions
fprintf(stdout,"\r\n\r\n---------- XML test ----------\r\n");
XML_VERSION_INFO xI = {0};
x->Version(&xI);
fprintf(stdout,"XML version: %u.%u (%s)\r\n",xI.VersionHigh,xI.VersionLow,xI.RDate);
int m1 = x->MemoryUsage();
x->CompressMemory();
int m2 = x->MemoryUsage();
fprintf(stdout,"Memory used before/after compression: %u / %u bytes.\r\n",m1,m2);
fprintf(stdout,"XML header: %s\r\n",x->GetHeader()->operator const char *());
// Sample XMLElement functions
fprintf(stdout,"\r\n\r\n---------- XMLElement test ----------\r\n");
XMLElement* r = x->GetRootElement();
int nC = r->GetChildrenNum();
fprintf(stdout,"Root element has %u children.\r\n",nC);
for(int i = 0 ; i < nC ; i++)
{
XMLElement* ch = r->GetChildren()[i];
int nV = ch->GetVariableNum();
int nMaxElName = ch->GetElementName(0);
char* n = new char[nMaxElName + 1];
ch->GetElementName(n);
fprintf(stdout,"\t Child %u: Variables: %u , Name: %s\r\n",i,nV,n);
delete[] n;
}
// Add a children to the end
r->AddElement(new XMLElement(r,(char*)"<testel x=\"1\" />"));
// Find this element by name
XMLElement* el = r->FindElementZ("testel");
if (!el)
fprintf(stderr,"Error, element not found!\r\n");
else
{
// Add some variables
el->AddVariable(new XMLVariable("somename","somevalue"));
// Note that the new XMLVariable we added is now owned by el
// Export only this element
el->Export(stdout,1,XML_SAVE_MODE_ZERO); // this prints <testel somename="somevalue"/>
}
// Find an element that may not exist, get its variable X that may not exist, get
// a default value of 0
int v = r->FindElementZ("elx",true)->FindVariableZ("varx",true)->GetValueInt();
// Set it to 5, set some more
r->FindElementZ("elx",true)->FindVariableZ("varx",true)->SetValueInt(5);
r->FindElementZ("elx",true)->FindVariableZ("varx2",true)->SetValueInt(10);
// Printout it
// This would print: <elx varx="5" varx2="10"/>
r->FindElementZ("elx",true)->Export(stdout,1,XML_SAVE_MODE_ZERO);
// Remove the var we just added
int ix = r->FindElement("elx");
if (ix != -1)
r->RemoveVariable(ix);
// Other XMLElement functions
r->Copy(); // Copy entire thing to windows clipboard
XMLElement* nP = XML::Paste();
if (nP)
//.........这里部分代码省略.........
示例4: importFromXML
bool XMLfile::importFromXML ()
{
//Ejemplo: <importfrom xml="eutibot.xml" element="euitibot" name="Robot1">
string name;
if (root->FindElementZ("importfrom"))
{
XMLElement* import=root->FindElementZ("importfrom");
if (import->FindVariableZ("xml"))
{
name=XMLAux::GetValueCadena(import->FindVariableZ("xml"));
XML* xmlImport = new XML(name.c_str());
XMLElement* rootImport = xmlImport->GetRootElement();
if (import->FindVariableZ("element"))
{
name=string();
name=XMLAux::GetValueCadena(import->FindVariableZ("element"));
if (rootImport->FindElementZ(name.c_str()))
{
imported=rootImport->FindElementZ(name.c_str())->Duplicate();
if (import->FindVariableZ("name"))
{
name=string();
name=XMLAux::GetValueCadena(import->FindVariableZ("name"));
if (imported->FindVariableZ("name"))
imported->FindVariableZ("name")->SetValue(name.c_str());
else
{
XMLVariable* _name=new XMLVariable ("name",name.c_str());
imported->AddVariable(_name);
}
}
return true;
}
else //search the XMLElement in another deep just in case
{
int num=rootImport->GetAllChildrenNum();
XMLElement** childsImport=new XMLElement*[num];
rootImport->GetAllChildren(childsImport);
for (int i=0;i<num;i++)
{
if (childsImport[i]->FindElementZ(name.c_str()))
{
imported=childsImport[i]->FindElementZ(name.c_str())->Duplicate();
if (import->FindVariableZ("name"))
{
name=string();
name=XMLAux::GetValueCadena(import->FindVariableZ("name"));
if (imported->FindVariableZ("name"))
imported->FindVariableZ("name")->SetValue(name.c_str());
else
{
XMLVariable* _name=new XMLVariable ("name",name.c_str());
imported->AddVariable(_name);
}
}
return true;
}
}
}
}
}
}
return false;
}