2012-02-27 12 views
0

私はXalanを使用しており、処理命令の入手方法を知りたいと思っています。 スタイルシート処理命令を取得したいと思います。XalanプログラムでXMLから処理命令を取得する方法は?

のthnx

+0

の可能重複[処理命令を選択するためのXPath式は?](http://stackoverflow.com/questions/9426910/what-is-the-xpath-expression-命令を選択する処理命令) – Flynn1179

答えて

0
 XMLPlatformUtils::Initialize(); 
     XPathEvaluator::initialize(); 
     { 
     const XalanDOMString   theFileName(fileName); 
     const LocalFileInputSource  theInputSource(theFileName.c_str()); 


     XalanSourceTreeInit    theSourceTreeInit; 
     XalanSourceTreeDOMSupport  theDOMSupport; 
     XalanSourceTreeParserLiaison theLiaison(theDOMSupport); 
     theDOMSupport.setParserLiaison(&theLiaison); 

     XalanDocument* const   theDocument = 
              theLiaison.parseXMLStream(theInputSource); 

     if(!theDocument) { 
      std::cerr << "Failed to create XalanDocument" << std::endl; 
      retValue = -1; 
     } 

     XalanDocumentPrefixResolver  thePrefixResolver(theDocument); 
     XPathEvaluator     theEvaluator; 

     XalanNode* const rootContextNode = theEvaluator.selectSingleNode(
               theDOMSupport, theDocument, 
          XalanDOMString("/processing-instruction('xml-stylesheet')").c_str(), 
               thePrefixResolver); 

     if(rootContextNode) { 
//<Now do whatever u want :)> 
     } 
関連する問題