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 David --- <da...@yahoo.fr> on 2004/03/15 15:39:22 UTC

Thanks now it works...!!! A sample like that could be included in the sample programs....

#Look for elements in a Domdocument 

for( std::vector<std::string>::iterator tag =
tags.begin(); tag !=tags.end(); tag++)
    {
	
	char *query = strdup((*tag).c_str());
	XMLCh* tmpstr = XMLString::transcode(query);
		
	int len;
	c_nodelist = c_doc->getElementsByTagName(tmpstr);
	
	len = c_nodelist->getLength();
	int i;
	char *name = NULL;
	char *value = NULL;
	
	//No result found
	if (len == 0) {
	    std::cout <<"###This entry does not contain any "
<<  "'" << *tag << "'"  << " element" << std::endl;
	    
	}
     
	//Found len results
	
	for (i=0; i < len ;i++)
	{
	    //Returns DOMnode object
	    c_node  = c_nodelist->item(i);
	    value =
XMLString::transcode(c_node->getTextContent());
	    name  =
XMLString::transcode(c_node->getNodeName());
	    std::cout <<"Index: " << i << std::endl;
	    std::cout << "Element: " <<
Transcode(c_node->getNodeName()).display() <<
std::endl;
 	    std::cout << "Value  : " <<
Transcode(c_node->getTextContent()).display() <<
std::endl;
	}
	free(query);
    }


	

	
		
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org