You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Gilles FILIPPINI <Gi...@edf.fr> on 2000/02/18 15:54:43 UTC

Réf. : Re: [Xerces C++] Usage

I had the idea about casting l1 to DOM_Element.
Unfortunately, such an operation seems not to be allowed by the Xerces DOM C++ implementation.

For example, with l1 being a DOM_Node, the statement :
	DOM_Element	elt = l1;
leads to the compilation error :
	Cannot use DOM_Node to initialize DOM_Element.

I also tried :
	DOM_Element	elt = DOM_Element(l1);
to obtain :
	Cannot cast from DOM_Node to DOM_Element

Any idea ?





braasch@ponton-software.de sur 18/02/2000 12:35:00
Pour :	Gilles FILIPPINI/SEPTEN/DE/EDFGDF/FR@EDFGDF, xerces-dev@xml.apache.org@hub
cc :	 
Objet :	Re: [Xerces C++] Usage

Hi Gilles,

Casting l1 to DOM_Element would the best solution, as far as I know. What kind
 of error
message to you get while doing it? Did you remember to call getChildNodes() on
 every
Level2 item to access the element values?

Regards,
Markus


---- snip ----

I know how to process each "Level1" element :

void MyClass::ProcessDocument(DOM_Document doc)
{
	DOM_NodeList dnl = doc.getElementsByTagName("Level1");
	for (unsigned int i = 0; i < dnl.getLength(); i++) {
		ProcessLevel1Element(dnl.item(i));
	}
}

But then, I don't know how to do to process "Level2" elements :

void MyClass::ProcessLevel1Element(DOM_Node l1)
{
	// I'd like to cast l1 into a DOM_Element to be able
	// to use getElementsByTagName("Level2") but it seems
	// impossible...
}

Did I miss a point ?
Thanks in advance.

- Gilles.