示例#1
0
文件: SXml.cpp 项目: hillwah/darkeden
void XMLTree::AddAttribute(const string& name, const string& value )
{
	ATTRIBUTES_MAP::iterator itr = m_AttributesMap.find(name);
	
	if (itr == m_AttributesMap.end() )
	{
		XMLAttribute *pAttr = new XMLAttribute(name, value);
		
		m_AttributesVector.push_back(pAttr);
		m_AttributesMap.insert(ATTRIBUTES_MAP::value_type(name, pAttr ));
	}
	else
	{
		XMLAttribute *pAttr = itr->second;
		pAttr->SetValue(value);
	}
}
示例#2
0
void XMLTreeNode::SetAttribute(char *name, char *value)
{
	XMLAttribute *a;

	a=GetAttribute(name);

	if (a)
		a->SetValue(value);
	else
	{
		a=attributes;

		if (a)
		{
			while (a->GetNext()) a=a->GetNext();

			a->SetNext(new XMLAttribute(a, name, value, 0));
		}
		else
		{
			a=attributes=new XMLAttribute(0, name, value, 0);
		}
	}
}