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 Moddy Te'eni <mt...@informatica.com> on 2009/05/13 11:08:54 UTC

no prefix after parsing with XercesDOMParser

I'm reading an XML file with the following code:

		const LocalFileInputSource	theInputSource(fileName);

		XercesDOMParser theParser;

		HandlerBase error_handler; 

		theParser.setErrorHandler(&error_handler);

		theParser.parse(theInputSource);

		DOMNode* node = theParser.getDocument();

		DOMNode* child = node->getFirstChild();
		cout << "name " << child->getNodeName() << endl;
		cout << "prefix " << child->getPrefix() << endl;

The input looks something like:

<aaa:ROOT xmlns:aaa="http://www.something/something">
<aaa:ELEMENT num="5"/>
</aaa:ROOT>

this outputs name to be "aaa:ROOT, and the prefix to be empty.

Why is it? How can i make it work correctly?

(My real problem is that afterwords I run XPath queries on this using
Xalan's  XercesDOMWrapper, and it doesn't find anything)

Thanks, Moddy.


-- 
View this message in context: http://www.nabble.com/no-prefix-after-parsing-with-XercesDOMParser-tp23518159p23518159.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


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


Re: no prefix after parsing with XercesDOMParser

Posted by Alberto Massari <am...@datadirect.com>.
You need to turn namespace processing (by calling 
theParser.setDoNamespaces(true) ) in order to have them created.

Alberto

Moddy Te'eni ha scritto:
> I'm reading an XML file with the following code:
>
> 		const LocalFileInputSource	theInputSource(fileName);
>
> 		XercesDOMParser theParser;
>
> 		HandlerBase error_handler; 
>
> 		theParser.setErrorHandler(&error_handler);
>
> 		theParser.parse(theInputSource);
>
> 		DOMNode* node = theParser.getDocument();
>
> 		DOMNode* child = node->getFirstChild();
> 		cout << "name " << child->getNodeName() << endl;
> 		cout << "prefix " << child->getPrefix() << endl;
>
> The input looks something like:
>
> <aaa:ROOT xmlns:aaa="http://www.something/something">
> <aaa:ELEMENT num="5"/>
> </aaa:ROOT>
>
> this outputs name to be "aaa:ROOT, and the prefix to be empty.
>
> Why is it? How can i make it work correctly?
>
> (My real problem is that afterwords I run XPath queries on this using
> Xalan's  XercesDOMWrapper, and it doesn't find anything)
>
> Thanks, Moddy.
>
>
>   


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


Re: no prefix after parsing with XercesDOMParser

Posted by Moddy Te'eni <mt...@informatica.com>.
Thanks! Worked like a charm.



Moddy Te'eni wrote:
> 
> I'm reading an XML file with the following code:
> 
> 		const LocalFileInputSource	theInputSource(fileName);
> 
> 		XercesDOMParser theParser;
> 
> 		HandlerBase error_handler; 
> 
> 		theParser.setErrorHandler(&error_handler);
> 
> 		theParser.parse(theInputSource);
> 
> 		DOMNode* node = theParser.getDocument();
> 
> 		DOMNode* child = node->getFirstChild();
> 		cout << "name " << child->getNodeName() << endl;
> 		cout << "prefix " << child->getPrefix() << endl;
> 
> The input looks something like:
> 
> <aaa:ROOT xmlns:aaa="http://www.something/something">
> <aaa:ELEMENT num="5"/>
> </aaa:ROOT>
> 
> this outputs name to be "aaa:ROOT, and the prefix to be empty.
> 
> Why is it? How can i make it work correctly?
> 
> (My real problem is that afterwords I run XPath queries on this using
> Xalan's  XercesDOMWrapper, and it doesn't find anything)
> 
> Thanks, Moddy.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/no-prefix-after-parsing-with-XercesDOMParser-tp23518159p23519899.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


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