以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  XML CDATA 求助(急)  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=52706)


--  作者:kangtamqf
--  发布时间:9/16/2007 2:22:00 PM

--  XML CDATA 求助(急)
我的xml的文档是这样的:
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<DJStory>
<version>1.0</version>
<uniqueid>20070904DN000004</uniqueid>
<chainhistory>20070904DN000004</chainhistory>
<title>
<![CDATA[WSJ(9/4) Study Of Toddlers Links Obesity And Iron Deficiency]]>
</title>
<storydate>2007-09-04</storydate>
<storytime>04:00</storytime>
<codes codetype="country"></codes>
<codes codetype="subject">N/DJGP,N/DJI,N/WER,N/DJSS,N/DJWI,N/GEN,N/HLT,N/JNL,N/RND,N/WLS</codes>
<codes codetype="industry"></codes>
<codes codetype="page"></codes>
<codes codetype="layout">J/MNO,J/PSJ</codes>
<codes codetype="statistics"></codes>
<codes codetype="market">M/NND</codes>
<codes codetype="government"></codes>
<codes codetype="product">P/EMB,P/XDJN</codes>
<codes codetype="company"></codes>
<codes codetype="other"></codes>
<subtext/>
<fulltext><![CDATA[<FONT FACE="Arial" class="NormalMinus1">
<pre>
   (From THE WALL STREET JOURNAL)
   Associated Press
</pre>
</FONT>]]>
</fulltext>
</DJStory>
</root>
现在我想用java 程序取得title和fulltext的值,这两个都是CDATA的形式,但是我的程序只能取到fulltext,不能取到title,这个问题已经困扰我2天了,头大, 请教高人指点,谢谢。
NodeList nlCurrent = elmtCurrentRecord.getElementsByTagName(ConstantValue);
//ConstantValue可以取到title或者fulltext
for (int j = 0; j < nlCurrent.getLength(); j++) {  
              if(nlCurrent.item(0).hasChildNodes()){
         String xmlValues = nlCurrent.item(j).getFirstChild().getNodeValue();
                System.out.println("---------------: " + xmlValues);                                     
                if(xmlValues != null){
                      //xmlValues = xmlValues.trim();               
                      xmlValuesAL.add(xmlValues);
                 }
       }
}

--  作者:kangtamqf
--  发布时间:9/16/2007 4:23:00 PM

--  
Problem solved by Using different XML parser!
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
6,902.344ms