You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Josh Brown (GENERIZE)" <jo...@generize.com> on 2000/12/04 15:09:23 UTC

Going through the tree

I found out what the problem I was having was, and was hoping that someone
could help me with what the problem is.
The XML file I am trying to analyse looks like this:
<person>A
	<son>B
		<grandson>C</grandson>
		<granddaughter>D</granddaughter>
	</son>
	:
	:
	:
</person>

My code looks like this:
	Xerces::IXMLDOMDocumentPtr Source(__uuidof(Xerces::DOMDocument));
	short flag = Source->load("d:/jmb/path_test/test.xml");
	if (flag == -1)
	{
		Xerces::IXMLDOMElementPtr Root = Source->documentElement;
		strcpy(path,Root->tagName);
		Go_Through_Tree(Root);
	}

void Go_Through_Tree(Xerces::IXMLDOMElementPtr Here)
{
	int j;
	int children = Here->childNodes->length;
	for (j = 1; j < children; j++)
	{
		Xerces::IXMLDOMElementPtr child =
Here->GetchildNodes()->Getitem(j);
		int node_type = child->GetnodeType();
		if (node_type != Xerces::NODE_TEXT)
			Go_Through_Tree(child);
	}
}

When I run the program and it gets to the point of dealing with the son
portrayed above, I get that children = 5. When I check things through VB, I
find that after each child (<son> and <daughter>) there is now a new node.
When I explore it in VB, it shows me that it is a NODE_TEXT, however when I
try reading it in my program, ->GetnodeType returns an error.
What are these mystery nodes? Are they automatically created? Why can't I
"find" them with GetItem?
Thanx in advance,
	Josh Brown

Re: Going through the tree [COM]

Posted by Bill Schindler <de...@bitranch.com>.
"Josh Brown  (GENERIZE)" <jo...@generize.com> wrote:
> for (j = 1; j < children; j++)
> {
> 	Xerces::IXMLDOMElementPtr child = Here->GetchildNodes()->Getitem(j);
>	int node_type = child->GetnodeType();
>	if (node_type != Xerces::NODE_TEXT)
>		Go_Through_Tree(child);
> }

After grepping around in Xerces' source, I finally figured out that this is
COM. (Until then, I was completely mystified.) I've added a [COM] to the
subject in hope that we get one of the COM expert's attention.


--Bill