JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java & XML、Web Service  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 可以取到xml的name,取不到value.大傢幫忙看看??
擺渡人

來自:北灣村



發文: 32
積分: 0
於 2004-08-11 09:00 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
XML格式代馬:
1
2
3
4
5
.............
<answer>
   <ResultCode>aa</ResultCode>
   <Result>bb</Result>
</answer>

我用下面的去取這個(上麵是訪問一個servlet頁麵的返迴值.)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
............................................
       Writer out = new OutputStreamWriter( socket.getOutputStream(), "GB2312"); 
       out.write("GET /CPModule/cppushservlet?CP_Num=CP003&CP_Password=fuzhoumhnet&SP_ICP=8566&SP_SUB=123&Service_Comd=A&Service_Type=7&Dst_MSISDN=13358253175&Service_Version=1&SMS_Content=短信内容(GBK编码)&SMS_Fmt=15&Fee_MSISDN=13358253175&Seq_Num=4567 HTTP/1.1\r\n"); 
       out.write("Host: " + TARGET_HTTPS_SERVER + ":" +  TARGET_HTTPS_PORT + "\r\n"); 
 
       out.write("\r\n"); 
       out.flush(); 
      // BufferedReader in = new BufferedReader( new InputStreamReader(socket.getInputStream(), "GB2312")); 
   
      // while ((line = in.readLine()) != null) { 
    //    System.out.println("line=="+line); 
     //  } 
 
             InputStream is = socket.getInputStream();
             DocumentBuilderFactory df = DocumentBuilderFactory.newInstance();
             DocumentBuilder db = df.newDocumentBuilder();
             Document doc = db.parse(is);
       System.out.println("parse successfull");
 
         Element root = doc.getDocumentElement();
               NodeList nl = root.getChildNodes();
         System.out.println("length=="+nl.getLength());
               Node tempNode = null;
          for(int i=0;i<nl.getLength();i++)
                {
                        tempNode = nl.item(i);
                        nodeName = tempNode.getNodeName();
                        nodeValue = tempNode.getNodeValue();
                        System.out.println("nodeName=="+nodeName);
            System.out.println("nodeValue=="+nodeValue);
 
               }
............................................

上面是個main.執行結果如下:
parse successfull
length==2
nodeName==ResultCode
nodeValue==null (怎麼這個為null值)
nodeName==Result
nodeValue==null (怎麼這個為null值)

請問那裡錯了.............????


擺渡人 edited on 2004-08-17 12:01
reply to postreply to post
記憶太長~
心事太重~
夢想太多~
話題樹型展開
人氣 標題 作者 字數 發文時間
3466 可以取到xml的name,取不到value.大傢幫忙看看?? 擺渡人 2444 2004-08-11 09:00
3082 Re:可以取到xml的name,取不到value.大傢幫忙看看?? allex 140 2004-08-16 18:05
2082 Re:可以取到xml的name,取不到value.大傢幫忙看看?? teresayu 1024 2007-10-17 23:51
» JWorld@TW »  Java & XML、Web Service

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8