Hi!
That's a thing for Xalan. I do it that way. First I use Xerces (DOM) to do some
stuff and then I wrap the DOM-tree and pass it to Xalan.
More or less like this:
try
{
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch)
{
char* message = XMLString::transcode(toCatch.getMessage());
// throw exception with message
}
impl =
DOMImplementationRegistry::getDOMImplementation(XMLString::transcode("LS"));
parser = ((DOMImplementationLS*)
impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
doc = parser->parseURI("inputfile.xml");
// do stuff with doc
// use Xalan to evaluate xPath's
XPathEvaluator::initialize();
XPathEvaluator eval;
XercesDOMSupport domsupport;
XercesParserLiaison parserLiaison; // for communication
// xml-file is already parsed. don't want to do that again
const XercesDOMWrapperParsedSource parsedSource(
doc,
parserLiaison,
domsupport);
// count nodes as example
XalanDocument* xalanDoc = parsedSource.getDocument();
// get root node
XalanElement* rootElement= xalanDoc->getDocumentElement();
// select all nodes that matches xPath
// read xPath from user or whatever
NodeRefList nodelist = eval.selectNodeList (domsupport, (XalanNode*)
rootElement, XalanDOMString(xpath.c_str()).c_str());
int elements = nodelist.getLength();
// and so on
Don't know if this is the fastest way do to stuff. It is just one way to do it..
.
You can also manipulate trees (I think?) with Xalan and write them back using
Xerces
//daniel
[EMAIL PROTECTED] (2003-07-21 03:34):
>Hi folks,
>
>not sure if I'm barking up the wrong tree here, but is there an API to
>extract nodes from a file (or DOM) using XPath strings? This would be a
>really powerful feature for manipulating trees.
>
>==============================
>Oliver White
>Software Engineer
>Product Development
>Westinghouse Signals Australia
>==============================
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]