新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> XML编辑器,XML解析器,XML开发环境
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XML工具及XML开发环境 』 → 请教关于xml4c的使用 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 4354 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 请教关于xml4c的使用 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     luling98 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:0
      积分:54
      注册:2003/11/10

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给luling98发送一个短消息 把luling98加入好友 查看luling98的个人资料 搜索luling98在『 XML工具及XML开发环境 』的所有贴子 引用回复这个贴子 回复这个贴子 查看luling98的博客楼主
    发贴心情 请教关于xml4c的使用

    有没有哪位大侠用过的,可不可以指导一番,或者推荐能够了解相关信息的站点?不甚感激啊!!

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2003/11/10 11:13:00
     
     Yinjs 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:2
      积分:56
      注册:2003/12/17

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给Yinjs发送一个短消息 把Yinjs加入好友 查看Yinjs的个人资料 搜索Yinjs在『 XML工具及XML开发环境 』的所有贴子 引用回复这个贴子 回复这个贴子 查看Yinjs的博客2
    发贴心情 

    我现在属性值可以拿出来,但是NodeValue拿不出来。
    一起参考吗。
    #include <xercesc/dom/DOM.hpp>
    #include <xercesc/util/XMLString.hpp>
    #include <xercesc/util/PlatformUtils.hpp>
    #include <iostream.h>
    XERCES_CPP_NAMESPACE_USE


    class XStr
    {
    public :
        // -----------------------------------------------------------------------
        //  Constructors and Destructor
        // -----------------------------------------------------------------------
        XStr(const char* const toTranscode)
        {
            // Call the private transcoding method
            fUnicodeForm = XMLString::transcode(toTranscode);
        }

        ~XStr()
        {
            XMLString::release(&fUnicodeForm);
        }


        // -----------------------------------------------------------------------
        //  Getter methods
        // -----------------------------------------------------------------------
        const XMLCh* unicodeForm() const
        {
            return fUnicodeForm;
        }

    private :
        // -----------------------------------------------------------------------
        //  Private data members
        //
        //  fUnicodeForm
        //      This is the Unicode XMLCh format of the string.
        // -----------------------------------------------------------------------
        XMLCh*   fUnicodeForm;
    };

    #define X(str) XStr(str).unicodeForm()
        int main (int argc, char* args[]) {

            try {
                XMLPlatformUtils::Initialize();
            }
            catch (const XMLException& toCatch) {
                char* message = XMLString::transcode(toCatch.getMessage());
                cout << "Error during initialization! :\n"
                     << message << "\n";
                XMLString::release(&message);
                return 1;
            }


            XMLCh tempStr[100];
            XMLString::transcode("LS", tempStr, 99);
            DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
            DOMBuilder* parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);

            // optionally you can set some features on this builder
            if (parser->canSetFeature(XMLUni::fgDOMValidation, true))
                parser->setFeature(XMLUni::fgDOMValidation, true);
            if (parser->canSetFeature(XMLUni::fgDOMNamespaces, true))
                parser->setFeature(XMLUni::fgDOMNamespaces, true);
            if (parser->canSetFeature(XMLUni::fgDOMDatatypeNormalization, true))
                parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);


            // optionally you can implement your DOMErrorHandler (e.g. MyDOMErrorHandler)
            // and set it to the builder
            //DOMErrorHandler* errHandler = new DOMErrorHandler();
            //parser->setErrorHandler(errHandler);

            char* xmlFile = "d:\\ttt.xml";
            DOMDocument *doc = 0;

            try {
       cout << "begin" << endl;
                doc = parser->parseURI(xmlFile);
       /*DOMNodeList *nodelist = doc->getElementsByTagName(X("data"));
          for(unsigned int i=0; i < doc->getElementsByTagName(X("data"))->getLength() ; i++){
            DOMNode  *node = nodelist->item(i);
          const XMLCh*   ch =  node->getNodeName();
       */
       DOMElement *  dome = doc->getDocumentElement () ;
                DOMNodeList *nodelist = dome->getElementsByTagName(X("data"));
       for(unsigned int i=0; i < doc->getElementsByTagName(X("data"))->getLength() ; i++){
             //DOMNode  *node = nodelist->item(i);
          DOMText  * node = (  DOMText  *)(nodelist->item(i));
        //const XMLCh*   ch =  dome->getAttribute(X("CRCTYPE")) ;
           //const XMLCh* ch3 = node->getAttribute (X("name"));
           //cout << "     " << XMLString::transcode(ch3) << endl;

        const XMLCh* ch4 = node->getNodeValue ();
           cout << "     " << XMLString::transcode(ch4) << endl;
        //const DOMTypeInfo* info = node->getTypeInfo () ;
        //DOMAttr *  doma = node->getAttributeNode(X("*"));
        //const XMLCh* ch4 = doma->getValue ();
        //const XMLCh* ch4 = info->getName();
        //cout << "     " << XMLString::transcode(ch4) << endl;
                    
        
       
             //const XMLCh*   ch1 =  node->getNodeName();
        // DOMElement *  de = (node->getOwnerDocument())->getDocumentElement () ;
           // const XMLCh* ch4 = de->getTagName ();
       //cout << XMLString::transcode(ch4) << endl;
          
         // cout << XMLString::transcode(ch1) << endl;
       }
          const XMLCh*   ch =  dome->getAttribute(X("CRCTYPE")) ;
       const XMLCh* ch2 = dome->getTagName ();
       cout << XMLString::transcode(ch2) << endl;
       //DOMAttr * domatt = dome->getAttributeNode(X("CRCTYPE"));  
                //const XMLCh* ch3 = domatt->getName ();
       //cout << XMLString::transcode(ch3) << endl;
       //short shint =node->getNodeType();
                //const XMLCh*   ch1  =  node->getNodeValue();
       //DOMNamedNodeMap * map = node->getAttributes ()  ;
       //DOMNode *node3 = map->getNamedItem(X("SMAPSML"));
      // const XMLCh*   ch2 =  node3->getNodeName();
      // cout << XMLString::transcode(ch2) << endl;
       //for(int j=0;j<map->getLength();j++){
                //   DOMNode *node1 = map->item(i);
                //   const XMLCh*   ch1 =  node->getNodeName();
        //  cout << XMLString::transcode(ch1) << endl;
       //}
       cout << XMLString::transcode(ch) << endl;
     // }
            }
            catch (const XMLException& toCatch) {
                char* message = XMLString::transcode(toCatch.getMessage());
                cout << "Exception message is: \n"
                     << message << "\n";
                XMLString::release(&message);
                return -1;
            }
            catch (const DOMException& toCatch) {
                char* message = XMLString::transcode(toCatch.msg);
                cout << "Exception message is: \n"
                     << message << "\n";
                XMLString::release(&message);
                return -1;
            }
            catch (...) {
                cout << "Unexpected Exception \n" ;
                return -1;
            }

            parser->release();
    //        delete errHandler;
            return 0;
        }

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2003/12/17 13:54:00
     
     Yinjs 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:2
      积分:56
      注册:2003/12/17

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给Yinjs发送一个短消息 把Yinjs加入好友 查看Yinjs的个人资料 搜索Yinjs在『 XML工具及XML开发环境 』的所有贴子 引用回复这个贴子 回复这个贴子 查看Yinjs的博客3
    发贴心情 
    在取得node后,用node->getFirstChild() ,在用node->getNodeValue()
    就可取出来了。
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2003/12/19 9:32:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XML工具及XML开发环境 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/5/12 6:50:16

    本主题贴数3,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    93.750ms