TiXmlElement* Vec3::GenerateOverridesXML( TiXmlElement* pResource ) const { TiXmlElement* pRetNode = GernerateXML(); if( !std::strcmp( pRetNode->Attribute( "x" ), pResource->Attribute( "x" ) ) && !std::strcmp( pRetNode->Attribute( "y" ), pResource->Attribute( "y" ) ) && !std::strcmp( pRetNode->Attribute( "z" ), pResource->Attribute( "z" ) ) ) { pRetNode->RemoveAttribute( "x" ); pRetNode->RemoveAttribute( "y" ); pRetNode->RemoveAttribute( "z" ); } return pRetNode; }
TiXmlElement* Color::GenerateOverridesXML( TiXmlElement* pResource ) { TiXmlElement* pRetNode = GenerateXML(); if( !std::strcmp( pRetNode->Attribute( "r" ), pResource->Attribute( "r" ) ) && !std::strcmp( pRetNode->Attribute( "g" ), pResource->Attribute( "g" ) ) && !std::strcmp( pRetNode->Attribute( "b" ), pResource->Attribute( "b" ) ) && !std::strcmp( pRetNode->Attribute( "a" ), pResource->Attribute( "a" ) ) ) { pRetNode->RemoveAttribute( "r" ); pRetNode->RemoveAttribute( "g" ); pRetNode->RemoveAttribute( "b" ); pRetNode->RemoveAttribute( "a" ); } return pRetNode; }
void CALLBACK CUICommandHistory::UIModify(TiXmlNode* pNode) { TiXmlElement* pElement = pNode->ToElement(); CStringA strName = pElement->Attribute("myname"); pElement->RemoveAttribute("myname"); if(strName.IsEmpty()) return; CPaintManagerUI* pManager = g_pMainFrame->GetActiveUIView()->GetPaintManager(); CControlUI* pControl = pManager->FindControl(StringConvertor::Utf8ToWide(strName)); TiXmlAttribute* pAttrib = pElement->FirstAttribute(); if(pControl == NULL) return; while(pAttrib) { if(strcmp(pAttrib->Name(), "name") == 0) { pManager->ReapObjects(pControl); g_pClassView->RenameUITreeItem(pControl, StringConvertor::Utf8ToWide(pAttrib->Value())); pControl->SetAttribute(StringConvertor::Utf8ToWide(pAttrib->Name()) , StringConvertor::Utf8ToWide(pAttrib->Value())); pManager->InitControls(pControl); } else pControl->SetAttribute(StringConvertor::Utf8ToWide(pAttrib->Name()) , StringConvertor::Utf8ToWide(pAttrib->Value())); pAttrib = pAttrib->Next(); } CControlUI* pParent = pControl->GetParent(); if(pParent == NULL) pParent = pControl; pParent->SetPos(pParent->GetPos()); }
void CALLBACK CUICommandHistory::UIAdd(TiXmlNode* pNode) { TiXmlElement* pElement = pNode->ToElement(); CStringA strParentName = pElement->Attribute("parentname"); pElement->RemoveAttribute("parentname"); if(strParentName.IsEmpty()) return; CUIDesignerView* pUIView = g_pMainFrame->GetActiveUIView(); CPaintManagerUI* pManager = pUIView->GetPaintManager(); CControlUI* pParentControl = pManager->FindControl(StringConvertor::Utf8ToWide(strParentName)); if(pParentControl == NULL) return; TiXmlDocument xmlDoc; TiXmlDeclaration Declaration("1.0","utf-8","yes"); xmlDoc.InsertEndChild(Declaration); TiXmlElement* pRootElem = new TiXmlElement("UIAdd"); pRootElem->InsertEndChild(*pElement); xmlDoc.InsertEndChild(*pRootElem); TiXmlPrinter printer; xmlDoc.Accept(&printer); delete pRootElem; CDialogBuilder builder; CControlUI* pRoot=builder.Create(StringConvertor::Utf8ToWide(printer.CStr()), (UINT)0, NULL, pManager); if(pRoot) pUIView->RedoUI(pRoot, pParentControl); }
void COptions::SetXmlValue(unsigned int nID, wxString value) { if (!m_pXmlFile) return; // No checks are made about the validity of the value, that's done in SetOption char *utf8 = ConvUTF8(value); if (!utf8) return; TiXmlElement *settings = m_pXmlFile->GetElement()->FirstChildElement("Settings"); if (!settings) { TiXmlNode *node = m_pXmlFile->GetElement()->InsertEndChild(TiXmlElement("Settings")); if (!node) { delete [] utf8; return; } settings = node->ToElement(); if (!settings) { delete [] utf8; return; } } else { TiXmlNode *node = 0; while ((node = settings->IterateChildren("Setting", node))) { TiXmlElement *setting = node->ToElement(); if (!setting) continue; const char *attribute = setting->Attribute("name"); if (!attribute) continue; if (strcmp(attribute, options[nID].name)) continue; setting->RemoveAttribute("type"); setting->Clear(); setting->SetAttribute("type", (options[nID].type == string) ? "string" : "number"); setting->InsertEndChild(TiXmlText(utf8)); delete [] utf8; return; } } wxASSERT(options[nID].name[0]); TiXmlElement setting("Setting"); setting.SetAttribute("name", options[nID].name); setting.SetAttribute("type", (options[nID].type == string) ? "string" : "number"); setting.InsertEndChild(TiXmlText(utf8)); settings->InsertEndChild(setting); delete [] utf8; }
void csTinyXmlNode::RemoveAttributes () { TiXmlElement* element = node->ToElement (); if (element) { for (size_t i = 0; i < element->GetAttributeCount (); i++) { TiDocumentAttribute& attrib = element->GetAttribute (i); element->RemoveAttribute(attrib.Name ()); } } }
void GD_EXTENSION_API RemoveAttribute(const std::string &refname, const std::string &property, RuntimeScene &scene) { TiXmlNode *refNode = RefManager::Get(&scene)->GetRef(refname); if(refNode) { TiXmlElement *refEle = refNode->ToElement(); if(refEle) { refEle->RemoveAttribute(property.c_str()); } } }
bool wxsItemResData::RebuildXrcFile() { // First - opening file TiXmlDocument Doc; TiXmlElement* Resources = nullptr; TiXmlElement* Object = nullptr; if ( TinyXML::LoadDocument(m_XrcFileName,&Doc) ) { Resources = Doc.FirstChildElement("resource"); } if ( !Resources ) { Doc.Clear(); Doc.InsertEndChild(TiXmlDeclaration("1.0","utf-8","")); Resources = Doc.InsertEndChild(TiXmlElement("resource"))->ToElement(); Resources->SetAttribute("xmlns","http://www.wxwidgets.org/wxxrc"); } // Searching for object representing this resource for ( Object = Resources->FirstChildElement("object"); Object; Object = Object->NextSiblingElement("object") ) { if ( cbC2U(Object->Attribute("name")) == m_ClassName ) { Object->Clear(); while ( Object->FirstAttribute() ) { Object->RemoveAttribute(Object->FirstAttribute()->Name()); } break; } } if ( !Object ) { Object = Resources->InsertEndChild(TiXmlElement("object"))->ToElement(); } // The only things left are: to dump item into object ... m_RootItem->XmlWrite(Object,true,false); Object->SetAttribute("name",cbU2C(m_ClassName)); for ( int i=0; i<GetToolsCount(); i++ ) { TiXmlElement* ToolElement = Object->InsertEndChild(TiXmlElement("object"))->ToElement(); m_Tools[i]->XmlWrite(ToolElement,true,false); } // ... and save back the file return TinyXML::SaveDocument(m_XrcFileName,&Doc); }
//--------------------------------------------------------- void ofxXmlSettings::removeAttribute(const string& tag, const string& attribute, int which){ vector<string> tokens = tokenize(tag,":"); TiXmlHandle tagHandle = storedHandle; for (int x = 0; x < (int)tokens.size(); x++) { if (x == 0) tagHandle = tagHandle.ChildElement(tokens.at(x), which); else tagHandle = tagHandle.FirstChildElement(tokens.at(x)); } if (tagHandle.ToElement()) { TiXmlElement* elem = tagHandle.ToElement(); elem->RemoveAttribute(attribute); } }
void csTinyXmlNode::RemoveAttribute (const csRef<iDocumentAttribute>& attribute) { TiXmlElement* element = node->ToElement (); if (element) { for (size_t i = 0 ; i < element->GetAttributeCount (); i++) { TiDocumentAttribute& attrib = element->GetAttribute (i); if (strcmp (attribute->GetName(), attrib.Name ()) == 0) { element->RemoveAttribute(attrib.Name()); } } } }
int em::EmXml::ClearRootAttr() { bool bUpdated = false; int iResult = 0; TiXmlElement *pElemRoot = m_pDoc->RootElement(); if(pElemRoot == NULL) { return 0; } while(pElemRoot->FirstAttribute()) { pElemRoot->RemoveAttribute(pElemRoot->FirstAttribute()->Name()); bUpdated = true; } m_bUpdated = bUpdated; return iResult; }
void readSchoolXml() { using namespace std; const char *xmlFile = "conf/school.xml"; TiXmlDocument doc; if (!doc.LoadFile(xmlFile)) { cout << "Load xml file failed.\t" << xmlFile << endl; return; } cout << "Load xml file OK." << endl; TiXmlDeclaration *decl = doc.FirstChild()->ToDeclaration(); if (!decl) { cout << "decl is null.\n" << endl; return; } cout << decl->Encoding(); cout << decl->Version(); cout << decl->Standalone() << endl; TiXmlHandle docHandle(&doc); TiXmlElement *child = docHandle.FirstChild("School").FirstChild("Class").Child("Student", 0).ToElement(); for ( ; child != NULL; child = child->NextSiblingElement()) { TiXmlAttribute *attr = child->FirstAttribute(); for (; attr != NULL; attr = attr->Next()) { cout << attr->Name() << " : " << attr->Value() << endl; } TiXmlElement *ct = child->FirstChildElement(); for (; ct != NULL; ct = ct->NextSiblingElement()) { char buf[1024] = {0}; u2g(ct->GetText(), strlen(ct->GetText()), buf, sizeof(buf)); cout << ct->Value() << " : " << buf << endl; } cout << "=====================================" << endl; } TiXmlElement *schl = doc.RootElement(); const char *value_t =schl->Attribute("name"); char buf[1024] = {0}; if ( u2g(value_t, strlen(value_t), buf, sizeof(buf)) == -1) { return; } cout << "Root Element value: " << buf << endl; schl->RemoveAttribute("name"); schl->SetValue("NewSchool"); cout << "Save file: " << (doc.SaveFile("conf/new.xml") ? "Ok" : "Failed") << endl; return ; TiXmlElement *rootElement = doc.RootElement(); TiXmlElement *classElement = rootElement->FirstChildElement(); TiXmlElement *studentElement = classElement->FirstChildElement(); // N 个 Student 节点 for ( ; studentElement!= NULL; studentElement = studentElement->NextSiblingElement()) { // 获得student TiXmlAttribute *stuAttribute = studentElement->FirstAttribute(); for (; stuAttribute != NULL; stuAttribute = stuAttribute->Next()) { cout << stuAttribute->Name() << " : " << stuAttribute->Value() << endl; } // 获得student的第一个联系方式 TiXmlElement *contact = studentElement->FirstChildElement(); for (; contact != NULL; contact = contact->NextSiblingElement()) { const char *text = contact->GetText(); char buf[1024] = {0}; if ( u2g(text, strlen(text), buf, sizeof(buf)) == -1) { continue; } cout << contact->Value() << " : " << buf << endl; } } }