Exemplo n.º 1
0
XMLNodeColl XMLElementNode::QueryChildren2(const char* path)
{
	char cpath[1024];
	strcpy_k(cpath, sizeof(cpath), path);

	char* ss[512];
	int n = split(cpath, '/', ss, 512);

	XMLNodeColl collRst;
	XMLNodeColl collTmp;

	collTmp.AddNode(this);
	int start = 0, end = collTmp.Size();

	for(int i=0; i<n; i++)
	{
		const char* realPath = ss[i];
		for(int k=start; k<end; k++)
		{
			XMLDomNode* pNode = collTmp.GetNode(k);
			XMLElementNode* pElemNode = pNode->ToElementNode();
			XMLNodeColl& coll = pElemNode->m_children;

			for(int j=0; j<coll.Size(); j++)
			{
				XMLDomNode* pChildNode = coll.GetNode(j);
				if(!pChildNode->IsTextNode())
				{
					if(pChildNode->ToElementNode()->m_tagName.icompare(realPath) == 0)
					{
						if(i != n-1)
						{
							collTmp.AddNode(pChildNode);
						}
						else
						{
							collRst.AddNode(pChildNode);
						}

					}
				}
			}
		}
		start = end;
		end = collTmp.Size();
	}

	return collRst;
}
Exemplo n.º 2
0
XMLNodeColl XMLElementNode::GetChildren(const char* tagName)
{
	XMLNodeColl coll;
	int c = m_children.Size();
	for(int i=0; i<c; i++)
	{
		XMLDomNode* pNode = m_children.GetNode(i);
		if(pNode->IsTextNode()) continue;
		XMLElementNode* pElemNode = pNode->ToElementNode();
		if(pElemNode->m_tagName.icompare(tagName) == 0)
		{
			coll.AddNode(pNode);
		}
	}
	return coll;
}