锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲色精品三区二区一区,亚洲无砖砖区免费,亚洲Av熟妇高潮30phttp://www.tkk7.com/dingdangxiaoma/category/30899.htmlzh-cnMon, 21 Apr 2008 17:49:50 GMTMon, 21 Apr 2008 17:49:50 GMT60JAVA XML 瑙f瀽涔嬩簲-緇煎悎灝忎緥瀛?/title><link>http://www.tkk7.com/dingdangxiaoma/articles/194569.html</link><dc:creator>鍙綋灝忛┈</dc:creator><author>鍙綋灝忛┈</author><pubDate>Mon, 21 Apr 2008 10:02:00 GMT</pubDate><guid>http://www.tkk7.com/dingdangxiaoma/articles/194569.html</guid><wfw:comment>http://www.tkk7.com/dingdangxiaoma/comments/194569.html</wfw:comment><comments>http://www.tkk7.com/dingdangxiaoma/articles/194569.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/dingdangxiaoma/comments/commentRss/194569.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/dingdangxiaoma/services/trackbacks/194569.html</trackback:ping><description><![CDATA[2008騫?鏈?1鏃?nbsp; Edited By DingDangXiaoMa<br /> xml鏂囦歡璇誨彇錛岀畝鍗曚緥瀛愩傝鍙朜O鍙夾DDR<br /> data_10k.xml<br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #000000;"><?</span><span style="color: #000000;">xml version</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">1.0</span><span style="color: #000000;">"</span><span style="color: #000000;"> encoding</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">UTF-8</span><span style="color: #000000;">"</span><span style="color: #000000;">?></span><span style="color: #000000;"><br /> </span><span style="color: #000000;"><</span><span style="color: #000000;">RESULT</span><span style="color: #000000;">></span><span style="color: #000000;"><br />     </span><span style="color: #000000;"><</span><span style="color: #000000;">VALUE</span><span style="color: #000000;">></span><span style="color: #000000;"><br />         </span><span style="color: #000000;"><</span><span style="color: #000000;">NO</span><span style="color: #000000;">></span><span style="color: #000000;">A1234</span><span style="color: #000000;"></</span><span style="color: #000000;">NO</span><span style="color: #000000;">></span><span style="color: #000000;"><br />         </span><span style="color: #000000;"><</span><span style="color: #000000;">ADDR</span><span style="color: #000000;">></span><span style="color: #000000;">鐪乆X鍘縓X闀嘪X璺疿孌礨X鍙?/span><span style="color: #000000;"></</span><span style="color: #000000;">ADDR</span><span style="color: #000000;">></span><span style="color: #000000;"><br />     </span><span style="color: #000000;"></</span><span style="color: #000000;">VALUE</span><span style="color: #000000;">></span><span style="color: #000000;"><br />     </span><span style="color: #000000;"><</span><span style="color: #000000;">VALUE</span><span style="color: #000000;">></span><span style="color: #000000;"><br />         </span><span style="color: #000000;"><</span><span style="color: #000000;">NO</span><span style="color: #000000;">></span><span style="color: #000000;">B1234</span><span style="color: #000000;"></</span><span style="color: #000000;">NO</span><span style="color: #000000;">></span><span style="color: #000000;"><br />         </span><span style="color: #000000;"><</span><span style="color: #000000;">ADDR</span><span style="color: #000000;">></span><span style="color: #000000;">鐪乆X甯俋X涔X鏉慩X緇?/span><span style="color: #000000;"></</span><span style="color: #000000;">ADDR</span><span style="color: #000000;">></span><span style="color: #000000;"><br />     </span><span style="color: #000000;"></</span><span style="color: #000000;">VALUE</span><span style="color: #000000;">></span><span style="color: #000000;"><br /> </span><span style="color: #000000;"></</span><span style="color: #000000;">RESULT</span><span style="color: #000000;">></span></div> DOM鏂瑰紡錛?br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #0000ff;">import</span><span style="color: #000000;"> java.io.File;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> javax.xml.parsers.DocumentBuilder;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> javax.xml.parsers.DocumentBuilderFactory;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.w3c.dom.Document;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.w3c.dom.NodeList;<br /> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> WDom {<br />     </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">static</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> main(String arge[]){<br />     </span><span style="color: #0000ff;">try</span><span style="color: #000000;">{<br />     File f</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> File(</span><span style="color: #000000;">"</span><span style="color: #000000;">data_10k.xml</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br />     DocumentBuilderFactory factory</span><span style="color: #000000;">=</span><span style="color: #000000;">DocumentBuilderFactory.newInstance();<br />     DocumentBuilder builder</span><span style="color: #000000;">=</span><span style="color: #000000;">factory.newDocumentBuilder();<br />     Document doc </span><span style="color: #000000;">=</span><span style="color: #000000;"> builder.parse(f);<br />     NodeList nl </span><span style="color: #000000;">=</span><span style="color: #000000;"> doc.getElementsByTagName(</span><span style="color: #000000;">"</span><span style="color: #000000;">VALUE</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br />     </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;i</span><span style="color: #000000;"><</span><span style="color: #000000;">nl.getLength();i</span><span style="color: #000000;">++</span><span style="color: #000000;">){<br />     System.out.print(</span><span style="color: #000000;">"</span><span style="color: #000000;">杞︾墝鍙風爜:</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> doc.getElementsByTagName(</span><span style="color: #000000;">"</span><span style="color: #000000;">NO</span><span style="color: #000000;">"</span><span style="color: #000000;">).item(i).getFirstChild().getNodeValue());<br />     System.out.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">杞︿富鍦板潃:</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> doc.getElementsByTagName(</span><span style="color: #000000;">"</span><span style="color: #000000;">ADDR</span><span style="color: #000000;">"</span><span style="color: #000000;">).item(i).getFirstChild().getNodeValue());<br />      }<br />     }</span><span style="color: #0000ff;">catch</span><span style="color: #000000;">(Exception e){<br />     e.printStackTrace();<br />     }<br />     }<br /> }</span></div> JDOM錛?br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #0000ff;">import</span><span style="color: #000000;"> java.io.File;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> java.util.List;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.jdom.Document;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.jdom.Element;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.jdom.input.SAXBuilder;<br /> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> WJDom {<br />     </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">static</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> main(String arge[]) {<br />     </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> {<br />     SAXBuilder builder </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> SAXBuilder();<br />     Document doc </span><span style="color: #000000;">=</span><span style="color: #000000;"> builder.build(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> File(</span><span style="color: #000000;">"</span><span style="color: #000000;">data_10k.xml</span><span style="color: #000000;">"</span><span style="color: #000000;">));<br />     Element foo </span><span style="color: #000000;">=</span><span style="color: #000000;"> doc.getRootElement();<br />     List allChildren </span><span style="color: #000000;">=</span><span style="color: #000000;"> foo.getChildren();<br />     </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;i</span><span style="color: #000000;"><</span><span style="color: #000000;">allChildren.size();i</span><span style="color: #000000;">++</span><span style="color: #000000;">) {<br />         System.out.print(</span><span style="color: #000000;">"</span><span style="color: #000000;">杞︾墝鍙風爜:</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> ((Element)allChildren.get(i)).getChild(</span><span style="color: #000000;">"</span><span style="color: #000000;">NO</span><span style="color: #000000;">"</span><span style="color: #000000;">).getText());<br />         System.out.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">杞︿富鍦板潃:</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> ((Element)allChildren.get(i)).getChild(</span><span style="color: #000000;">"</span><span style="color: #000000;">ADDR</span><span style="color: #000000;">"</span><span style="color: #000000;">).getText());<br />     }<br />     }</span><span style="color: #0000ff;">catch</span><span style="color: #000000;">(Exception e) {<br />     e.printStackTrace();<br />     }<br />     }<br /> }</span></div> SAX錛氾紙<span style="background-color: yellow;"><span style="background-color: yellow;">榪欎釜鏇翠笉鐭ラ亾鏄粈涔堟剰鎬濅簡錛燂紒</span><span style="background-color: #fffcf8;">錛?/span></span><br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #0000ff;">import</span><span style="color: #000000;"> javax.xml.parsers.SAXParser;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> javax.xml.parsers.SAXParserFactory;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.xml.sax.Attributes;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.xml.sax.InputSource;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.xml.sax.SAXException;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.xml.sax.helpers.DefaultHandler;<br /> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> WSAX </span><span style="color: #0000ff;">extends</span><span style="color: #000000;"> DefaultHandler {<br />     <span style="background-color: #fff670;"><span style="color: #000000;">java.util.Stack tags </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> java.util.Stack();</span></span></span><span style="color: #000000;"><br />     </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> WSAX() {<br />         </span><span style="color: #0000ff;">super</span><span style="color: #000000;">();<br />     }<br />     </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">static</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> main(String args[]) {<br />         </span><span style="color: #0000ff;">long</span><span style="color: #000000;"> lasting </span><span style="color: #000000;">=</span><span style="color: #000000;"> System.currentTimeMillis();<br />         </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> {<br />         SAXParserFactory sf </span><span style="color: #000000;">=</span><span style="color: #000000;"> SAXParserFactory.newInstance();<br />         SAXParser sp </span><span style="color: #000000;">=</span><span style="color: #000000;"> sf.newSAXParser();<br />         WSAX reader </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> WSAX();<br />         sp.parse(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> InputSource(</span><span style="color: #000000;">"</span><span style="color: #000000;">data_10k.xml</span><span style="color: #000000;">"</span><span style="color: #000000;">), reader);<br />         } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) {<br />         e.printStackTrace();<br />         }<br />         System.out.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">榪愯鏃墮棿錛?/span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> (System.currentTimeMillis() </span><span style="color: #000000;">-</span><span style="color: #000000;"> lasting) </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #000000;">"</span><span style="color: #000000;">姣</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br />     }<br />     </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> <span style="background-color: #fff670;">characters</span>(</span><span style="color: #0000ff;">char</span><span style="color: #000000;"> ch[], </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> start, </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> length) </span><span style="color: #0000ff;">throws</span><span style="color: #000000;"> SAXException {<br />         String tag </span><span style="color: #000000;">=</span><span style="color: #000000;"> (String) tags.peek();<br />         </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (tag.equals(</span><span style="color: #000000;">"</span><span style="color: #000000;">NO</span><span style="color: #000000;">"</span><span style="color: #000000;">)) {<br />         System.out.print(</span><span style="color: #000000;">"</span><span style="color: #000000;">杞︾墝鍙風爜錛?/span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> String(ch, start, length).trim());<br />         }<br />         </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (tag.equals(</span><span style="color: #000000;">"</span><span style="color: #000000;">ADDR</span><span style="color: #000000;">"</span><span style="color: #000000;">)) {<br />             System.out.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">鍦板潃:</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> String(ch, start, length).trim());<br />         }<br />     }<br />     </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> startElement(String uri,String localName,String qName,Attributes attrs) {<br />         <span style="background-color: #fff670;">tags.push(qName);</span><br />     }<br />     } <br /> </span></div> SAX鐨勬柟寮忚繍琛岋紝浼氭湁闂錛岃緭鍑虹殑緇撴灉銆侫DDR錛屼細鏈変笁琛岋紝榪欐槸涓轟粈涔堝憿錛?br /> <br /> DOM4j錛?br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #0000ff;">import</span><span style="color: #000000;"> java.io.File;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> java.util.Iterator;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.dom4j.Document;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.dom4j.Element;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> org.dom4j.io.SAXReader;<br /> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> WDOM4j {<br /> <br />     </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">static</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> main(String arge[]) {<br />     </span><span style="color: #0000ff;">long</span><span style="color: #000000;"> lasting </span><span style="color: #000000;">=</span><span style="color: #000000;"> System.currentTimeMillis();<br />     </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> {<br />     File f </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> File(</span><span style="color: #000000;">"</span><span style="color: #000000;">data_10k.xml</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br />     SAXReader reader </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> SAXReader();<br />     Document doc </span><span style="color: #000000;">=</span><span style="color: #000000;"> reader.read(f);<br />     Element root </span><span style="color: #000000;">=</span><span style="color: #000000;"> doc.getRootElement();<br />     Element foo;<br />     </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (Iterator i </span><span style="color: #000000;">=</span><span style="color: #000000;"> root.elementIterator(</span><span style="color: #000000;">"</span><span style="color: #000000;">VALUE</span><span style="color: #000000;">"</span><span style="color: #000000;">); i.hasNext();) {<br />     foo </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Element) i.next();<br />     System.out.print(</span><span style="color: #000000;">"</span><span style="color: #000000;">杞︾墝鍙風爜:</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> foo.elementText(</span><span style="color: #000000;">"</span><span style="color: #000000;">NO</span><span style="color: #000000;">"</span><span style="color: #000000;">));<br />     System.out.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">杞︿富鍦板潃:</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> foo.elementText(</span><span style="color: #000000;">"</span><span style="color: #000000;">ADDR</span><span style="color: #000000;">"</span><span style="color: #000000;">));<br />     }<br />     } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception e) {<br />     e.printStackTrace();<br />     }<br />     }<br /> }</span></div> <br /> 榪欏嚑縐嶆柟娉曠殑姣旇緝錛?a >http://java.chinaitlab.com/XMLBeans/717370.html</a><br /> DOM錛岃繕鏄渶鍩虹鐨勬搷浣溿傚彟澶栵紝DOM4j,鍦ㄧ幇鍦ㄧ殑java妗嗘灦涓篃鏈夊簲鐢ㄣ?br /> 濂戒簡灝卞埌榪欓噷錛屽氨鏄畝鍗曠殑緇煎悎浜嗐傛湁鏈轟細鍐嶅啓鍐欎緥瀛愬惂銆?br /> <img src ="http://www.tkk7.com/dingdangxiaoma/aggbug/194569.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/dingdangxiaoma/" target="_blank">鍙綋灝忛┈</a> 2008-04-21 18:02 <a href="http://www.tkk7.com/dingdangxiaoma/articles/194569.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>JAVA XML 瑙f瀽涔嬪洓 -SAXhttp://www.tkk7.com/dingdangxiaoma/articles/194558.html鍙綋灝忛┈鍙綋灝忛┈Mon, 21 Apr 2008 09:34:00 GMThttp://www.tkk7.com/dingdangxiaoma/articles/194558.htmlhttp://www.tkk7.com/dingdangxiaoma/comments/194558.htmlhttp://www.tkk7.com/dingdangxiaoma/articles/194558.html#Feedback0http://www.tkk7.com/dingdangxiaoma/comments/commentRss/194558.htmlhttp://www.tkk7.com/dingdangxiaoma/services/trackbacks/194558.html SAX 鏄噰鐢ㄤ簨浠墮┍鍔ㄧ殑鏂瑰紡涓嶥om鏈澶х殑涓嶅悓鏄紝瀹冧笉鐢ㄨ鍙栧畬鎵鏈夌殑XML鏂囦歡灝卞彲浠ヨ繘琛屽鐞嗐傞噰鐢ㄦ祦寮忕殑澶勭悊鏂瑰紡(鍛?鍛碉紝鎴戜篃涓嶇煡閬撴槸浠涔堟剰鎬?/span>)
example:
娉ㄥ唽鍐呭綆$悊鍣細MyContentHandler.java
public class MyContentHandler implements ContentHandler {
    
// DTD涓畾涔夌殑鍏冪礌
    private static final String ELEMENT_NAME = "name";
    
private static final String ELEMENT_SEX = "sex";
    
private static final String ELEMENT_LESSON = "lesson";
    
private static final String ELEMENT_LESSON_NAME = "lessonName";
    
private static final String ELEMENT_LESSON_SCORE = "lessonScore";
    
private static final String ELEMENT_STUDENT = "student";
    
private static final String ELEMENT_LINE = "breakLine";

    
private String currentData = ""// 褰撳墠鍏冪礌鐨勬暟鎹?/span>
    private String lessonName = "";
    
private String lessonScore = "";

    
public MyContentHandler() {
    }

    
/**
     * 褰撳叾浠栨煇涓涓皟鐢ㄤ簨浠跺彂鐢熸椂錛屽厛璋冪敤姝ゆ柟娉曟潵鍦ㄦ枃妗d腑瀹氫綅銆?br />      * 
     * 
@param locator
     
*/
    
public void setDocumentLocator(Locator locator) {

    }

    
/**
     * 鍦ㄨВ鏋愭暣涓枃妗e紑濮嬫椂璋冪敤
     * 
     * 
@throws SAXException
     
*/
    
public void startDocument() throws SAXException {
        System.out.println(
"**** Student information start ****");
    }

    
/**
     * 鍦ㄨВ鏋愭暣涓枃妗g粨鏉熸椂璋冪敤
     * 
     * 
@throws SAXException
     
*/
    
public void endDocument() throws SAXException {
        System.out.println(
"**** Student information end ****");
    }

    
/**
     * 鍦ㄨВ鏋愬悕瀛楃┖闂村紑濮嬫椂璋冪敤
     * 
     * 
@param prefix
     * 
@param uri
     * 
@throws SAXException
     
*/
    
public void startPrefixMapping(String prefix, String uri)
            
throws SAXException {

    }

    
/**
     * 鍦ㄨВ鏋愬悕瀛楃┖闂寸粨鏉熸椂璋冪敤
     * 
     * 
@param prefix
     * 
@throws SAXException
     
*/
    
public void endPrefixMapping(String prefix) throws SAXException {

    }

    
/**
     * 鍦ㄨВ鏋愬厓绱犲紑濮嬫椂璋冪敤
     * 
     * 
@param namespaceURI
     * 
@param localName
     * 
@param qName
     * 
@param atts
     * 
@throws SAXException
     
*/
    
public void startElement(String namespaceURI, String localName,
            String qName, Attributes atts) 
throws SAXException {

    }

    
/**
     * 鍦ㄨВ鏋愬厓绱犵粨鏉熸椂璋冪敤
     * 
     * 
@param namespaceURI
     * 
@param localName
     *            鏈湴鍚嶏紝濡俿tudent
     * 
@param qName
     *            鍘熷鍚嶏紝濡侺IT:student
     * 
@throws SAXException
     
*/
    
public void endElement(String namespaceURI, String localName, String qName)
            
throws SAXException {
        
if (localName.equals(ELEMENT_NAME)) {
            System.out.println(localName 
+ ":" + currentData);
        }

        
if (localName.equals(ELEMENT_SEX)) {
            System.out.println(localName 
+ ":" + currentData);
        }

        
if (localName.equals(ELEMENT_LESSON_NAME)) {
            
this.lessonName = currentData;
        }

        
if (localName.equals(ELEMENT_LESSON_SCORE)) {
            
this.lessonScore = currentData;
        }

        
if (localName.equals(ELEMENT_LESSON)) {
            System.out.println(lessonName 
+ ":" + lessonScore);
        }

        
if (localName.equals(ELEMENT_LINE)) {
            System.out.println(
"------------------------------------");
        }
    }

    
/**
     * 鍙栧緱鍏冪礌鏁版嵁
     * 
     * 
@param ch
     * 
@param start
     * 
@param length
     * 
@throws SAXException
     
*/
    
public void characters(char[] ch, int start, int length)
            
throws SAXException {
        currentData 
= new String(ch, start, length).trim();
    }

    
/**
     * 鍙栧緱鍏冪礌鏁版嵁涓殑絀虹櫧
     * 
     * 
@param ch
     * 
@param start
     * 
@param length
     * 
@throws SAXException
     
*/
    
public void ignorableWhitespace(char[] ch, int start, int length)
            
throws SAXException {

    }

    
/**
     * 鍦ㄨВ鏋愬埌澶勭悊鎸囦護鏃訛紝璋冪敤姝ゆ柟娉曘?nbsp;榪欎簺澶勭悊鎸囦護涓嶅寘鎷琗ML鐨勭増鏉冩寚浠わ紝瀹冪敱瑙f瀽鍣ㄦ湰韜瘑鍒?br />      * 
     * 
@param target
     * 
@param data
     * 
@throws SAXException
     
*/
    
public void processingInstruction(String target, String data)
            
throws SAXException {

    }

    
/**
     * 褰撴湭楠岃瘉瑙f瀽鍣ㄥ拷鐣ュ疄浣撴椂璋冪敤姝ゆ柟娉?br />      * 
     * 
@param name
     * 
@throws SAXException
     
*/
    
public void skippedEntity(String name) throws SAXException {

    }
閿欒綆$悊鍣細MyErrorHandler.java
public class MyErrorHandler implements ErrorHandler {

    
public MyErrorHandler() {
    }

    
/**
     * XML鐨勮鍛婁俊鎭?br />      * 
     * 
@param exception
     * 
@throws SAXException
     
*/
    
public void warning(SAXParseException exception) throws SAXException {
        System.out.println(
"!!!WARNING!!!");
        System.out.println(exception.getLineNumber() 
+ ":("
                
+ exception.getSystemId() + ")" + exception.getMessage());
    }

    
/**
     * 涓嶇鍚圶ML瑙勮寖鏃惰皟鐢ㄦ鏂規硶
     * 
     * 
@param exception
     * 
@throws SAXException
     
*/
    
public void error(SAXParseException exception) throws SAXException {
        System.out.println(
"!!!ERROR!!!");
        System.out.println(exception.getLineNumber() 
+ ":("
                
+ exception.getSystemId() + ")" + exception.getMessage());
    }

    
/**
     * 闈炶壇鏋勭殑鏂囨。鏃惰皟鐢ㄦ鏂規硶
     * 
     * 
@param exception
     * 
@throws SAXException
     
*/
    
public void fatalError(SAXParseException exception) throws SAXException {
        System.out.println(
"!!!FATAL!!!");
        System.out.println(exception.getLineNumber() 
+ ":("
                
+ exception.getSystemId() + ")" + exception.getMessage());
    }
}
DTD 綆$悊鍣細 MyDTDHandler.java
public class MyDTDHandler implements DTDHandler {

    
public MyDTDHandler() {
    }

    
/**
     * 褰撳疄浣撳0鏄庝負涓嶅繀瑙f瀽鐨勫疄浣撴椂璋冪敤姝ゆ柟娉曪紝姣斿NDATA綾誨瀷銆?br />      * 
     * 
@param name
     * 
@param publicId
     * 
@param systemId
     * 
@throws SAXException
     
*/
    
public void notationDecl(String name, String publicId, String systemId)
            
throws SAXException {
        System.out.println(
"**notationDecl**");
        System.out.println(
"name:" + name);
        System.out.println(
"publicId" + publicId);
        System.out.println(
"systemId:" + systemId);
    }

    
/**
     * 褰撳鐞嗙鍙峰0鏄庢椂璋冪敤姝ゆ柟娉曪紝姣斿NOTATION銆?br />      * 
     * 
@param name
     * 
@param publicId
     * 
@param systemId
     * 
@param notationName
     * 
@throws SAXException
     
*/
    
public void unparsedEntityDecl(String name, String publicId,
            String systemId, String notationName) 
throws SAXException {
        System.out.println(
"**unparsedEntityDecl**");
        System.out.println(
"name:" + name);
        System.out.println(
"publicId" + publicId);
        System.out.println(
"systemId:" + systemId);
        System.out.println(
"notationName:" + notationName);
    }
}
SAX鏂瑰紡澶勭悊錛歁ySAXParser.java
import java.io.IOException;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
public class MySAXParser {
    
public MySAXParser() {
    }
    
public static void main(String[] args) {
        MySAXParser mySAXParser 
= new MySAXParser();
        mySAXParser.parserXMLFile(
"http://localhost/struts2.0/xml/SutInfo.xml");
    }
    
/**
     * 瑙f瀽鏂囨。XML鏂囨。鐨刄RI
     * 
@param fileURI
     
*/
    
private void parserXMLFile(String fileURI) {
        
try {
            
// 閫氳繃鎸囧畾瑙f瀽鍣ㄧ殑鍚嶇О鏉ュ姩鎬佸姞杞借В鏋愬櫒
            XMLReader parser = XMLReaderFactory
                    .createXMLReader(
"org.apache.xerces.parsers.SAXParser");
            
// 澶勭悊鍐呭鍓嶈娉ㄥ唽鍐呭綆$悊鍣?/span>
            parser.setContentHandler(new MyContentHandler());
            
// 澶勭悊閿欒鍓嶈娉ㄥ唽閿欒綆$悊鍣?/span>
            parser.setErrorHandler(new MyErrorHandler());
            
// 澶勭悊DTD鍓嶈娉ㄥ唽DTD綆$悊鍣?/span>
            parser.setDTDHandler(new MyDTDHandler());
            
// 鎵撳紑瑙f瀽鍣ㄧ殑楠岃瘉
            parser.setFeature("http://xml.org/sax/features/validation"true);
            
// 寮濮嬭В鏋愭枃妗?/span>
            parser.parse(fileURI);
        } 
catch (IOException ioe) {
            System.out.println(ioe.getMessage());
        } 
catch (SAXException saxe) {
            System.out.println(saxe.getMessage());
        }
    }
}
璇存槑錛?br /> org.xml.sax.*,鍖呭惈浜巎dk 涓?br /> 榪欎釜渚嬪瓙鏄?javaresearch 涓婄殑渚嬪瓙錛屾垜涔熸病鏈夊紕鏄庣櫧鏄粈涔堟剰鎬濓紝鍛點傚懙銆傝皝鑻ユ槸鐪嬪埌浜嗕簺璐達紝璇峰洖澶嶏紝璇翠竴璇存偍鐨勭湅娉曘?br />


]]>
JAVA XML 瑙f瀽涔嬩笁 -JDomhttp://www.tkk7.com/dingdangxiaoma/articles/194552.html鍙綋灝忛┈鍙綋灝忛┈Mon, 21 Apr 2008 09:16:00 GMThttp://www.tkk7.com/dingdangxiaoma/articles/194552.htmlhttp://www.tkk7.com/dingdangxiaoma/comments/194552.htmlhttp://www.tkk7.com/dingdangxiaoma/articles/194552.html#Feedback0http://www.tkk7.com/dingdangxiaoma/comments/commentRss/194552.htmlhttp://www.tkk7.com/dingdangxiaoma/services/trackbacks/194552.html JDOM鐨勭洰鐨勬槸鎴愪負Java鐗瑰畾鏂囨。妯″瀷錛屽畠綆鍖栦笌XML鐨勪氦浜掑茍涓旀瘮浣跨敤DOM瀹炵幇鏇村揩
example:
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
public class MyJDOM {
    
public MyJDOM() {
    }
    
public static void main(String[] args) {
        MyJDOM myJDOM 
= new MyJDOM();
        myJDOM.parserXMLFile(
"http://localhost/example/xml/SutInfo.xml"); //榪欐槸緗戠粶涓婄殑璧勬枡錛屼篃鍙互瀹氫箟涓烘湰鍦拌祫鏂欙紝閲囩敤鐩稿璺緞鐨勬柟寮忋?br />     }
    
/**
     * 瑙f瀽鏂囨。
     * 
     * 
@param fileURI
     
*/
    
private void parserXMLFile(String fileURI) {
        
try {
            
// 鑾峰緱org.jdom.input.SAXBuilder鐨勪竴涓疄渚嬶紝鐢ㄦ潵鑾峰緱XML鏂囨。銆?br />             // 鍙傛暟false琛ㄧず涓嶈繘琛岄獙璇併?br />             // 鍙傛暟涓病鏈夋寚瀹氫嬌鐢ㄤ粈涔堣В鏋愬櫒錛屽洜姝や嬌鐢ㄩ粯璁ょ殑瑙f瀽鍣ㄣ?/span>
            SAXBuilder builder = new SAXBuilder(false);
            
// 寰楀埌Document
            Document doc = builder.build(fileURI);
            
// 鍚嶅瓧絀洪棿
            Namespace ns = Namespace.getNamespace("LIT",
                    
"http://www.lit.edu.cn/student/");
            
// 寰楀埌鏍硅妭鐐筁IT:StuInfo
            Element elmtStuInfo = doc.getRootElement();
            
// 鍙栧緱鎵鏈塋IT:student鑺傜偣鐨勯泦鍚?/span>
            List lstStudents = elmtStuInfo.getChildren("student", ns);
            
// 淇敼bigmouse鐨凜AD鍒嗘暟
            for (int i = 0; i < lstStudents.size(); i++) {
                
// 褰撳墠瀛︾敓鑺傜偣
                Element elmtStudent = (Element) lstStudents.get(i);
                
if (elmtStudent.getChildTextTrim("name", ns).equals("bigmouse")) {
                    
// 鎵鏈夎紼嬭妭鐐圭殑闆嗗悎
                    List lstLesson = elmtStudent.getChildren("lesson", ns);
                    
for (int j = 0; j < lstLesson.size(); j++) {
                        Element elmtLesson 
= (Element) lstLesson.get(j);
                        
if (elmtLesson.getChildTextTrim("lessonName", ns)
                                .equals(
"autoCAD")) {
                            
// 淇敼CAD鍒嗘暟錛?00鍒?nbsp;@_@
                            elmtLesson.getChild("lessonScore", ns).setText("10");
                            System.out.println(
"** autoCAD:100");
                        }
                    }
                }
// end if
            }// end for
            
// 娣誨姞涓鏉″鐢熻褰?/span>
            elmtStuInfo
                    .addContent(
                            
new Element("student", ns)
                            .addContent(
new Element("name", ns).setText("fannWong"))
                            .addContent(
new Element("sex", ns).setText("female"))
                            .addContent(
new Element("lesson", ns)
                                .addContent(
new Element("lessonName",ns).setText("math"))
                                .addContent(
new Element("lessonScore",ns).setText("85")))
                            .addContent(
new Element("lesson", ns)
                                .addContent(
new Element("lessonName",ns).setText("English"))
                                .addContent(
new Element("lessonScore",ns).setText("95"))))
                    .addContent(
new Element("breakLine", ns));
            System.out.println(
"** New Element added!");
            
// 璋冩暣涓涓嬫牸寮忥紝鎶婂疄浣撳紩鐢ㄦ斁鍒版渶鍚庨潰
            
// 鍏堝垹闄わ紝鍚庤拷鍔犮?
            elmtStuInfo.removeChild("master", ns);
            elmtStuInfo.addContent(new Element("master", ns).addContent("master"));  //榪欏彞璇濓紝涓庡師濮嬫枃浠舵湁鎵涓嶅悓錛屼絾鎬葷殑浣滅敤灝卞湪鏈湯娣誨姞涓婁竴涓猰aster.

            
// 杈撳嚭鏂囨。
            
// 絎竴涓弬鏁版槸緙╄繘瀛楃涓詫紝榪欓噷鏄?涓┖鏍箋?br />             // 絎簩涓弬鏁版槸true錛岃〃紺洪渶瑕佹崲琛屻?/span>
            XMLOutputter printDoc = new XMLOutputter();
            printDoc.output(doc, new FileOutputStream("C:/Tomcat 6.0/webapps/struts2.0/xml/SutInfo2.xml")); //杈撳嚭鐨勬枃浠訛紝鍙互鏄師鏂囦歡涔熷彲鏄嚜瀹氫箟鏂囦歡銆?/span>
        } 
catch (JDOMException jdome) {
            System.out.println(jdome.getMessage());
        } 
catch (FileNotFoundException fnfe) {
            System.out.println(fnfe.getMessage());
        } 
catch (IOException ioe) {
            System.out.println(ioe.getMessage());
        }
    }
}
璇存槑錛?br /> 鏈師浠g爜鐨勪綔鐢ㄦ槸錛?.璇誨彇xml鏂囦歡錛屼慨鏀瑰悕瀛椾負bigmouse鐨凜AD鎴愮嘩銆?.鍦ㄦ湯灝炬坊鍔犱竴鏉¤褰曘?br /> 鍦ㄨ鍙栫粨鐐規椂錛屾渶鍚庣殑緇撶偣闆嗗叏鍙樻垚浜唈ava.util.List;鍛藉悕絀洪棿鏈夎嚜宸辯殑瀹氫箟綾?Namespace
鍦╦dk 涓粯璁ょ殑娌℃湁榪欎釜鍖?org.jdom.*.浠庣綉涓婁笅杞斤細http://www.jdom.org/
鏈皬鑺傚氨鍒拌繖閲岋紝鏈夊叴瓚g殑鍙互鍒嗘瀽涓涓嬪師浠g爜銆?涓嬩竴鑺?SAX鏂瑰紡銆?br />

]]>
JAVA XML 瑙f瀽涔嬩簩 -DOMhttp://www.tkk7.com/dingdangxiaoma/articles/194547.html鍙綋灝忛┈鍙綋灝忛┈Mon, 21 Apr 2008 08:54:00 GMThttp://www.tkk7.com/dingdangxiaoma/articles/194547.htmlhttp://www.tkk7.com/dingdangxiaoma/comments/194547.htmlhttp://www.tkk7.com/dingdangxiaoma/articles/194547.html#Feedback0http://www.tkk7.com/dingdangxiaoma/comments/commentRss/194547.htmlhttp://www.tkk7.com/dingdangxiaoma/services/trackbacks/194547.html DOM 鏂規硶瀵筙ML鐨勮В鏋愶紝鏄鍙栨暣涓?xml鏂囦歡錛屾妸淇℃伅瀛樺偍鍒板唴瀛樹腑褰㈡垚鏍戝瀷緇撴瀯錛岀劧鍚庡啀瀵瑰悇緇撶偣榪涜澶勭悊銆?br /> 濂藉錛氱畝鍗曪紝鏂逛究銆?br /> 鍧忓錛氱敱浜庤鍙栨暣涓枃浠跺啀榪涜澶勭悊錛屽鐞嗗ぇ鏂囦歡鏃訛紝鍗犵敤澶ч噺鍐呭瓨璧勬枡銆?br /> example:
import java.io.IOException;
import java.util.Hashtable;
import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class MyDOMParser {
    
// 鍚嶅瓧絀洪棿
    private String strNamespace = "http://www.lit.edu.cn/student/";
    
// 涓涓鐢熺殑璧勬枡
    private Hashtable htbStudent = new Hashtable();
    
// 鎵鏈夊鐢熺殑鍚戦噺鍒楄〃
    private Vector vStuInfo = new Vector();
    
public MyDOMParser() {
    }
    
public static void main(String[] args) {
        MyDOMParser myDOMParser 
= new MyDOMParser();
        myDOMParser.parseXMLFile(
"http://localhost/example/xml/SutInfo.xml");
    }
    
/**
     * 瑙f瀽鏂囨。
     * 
@param fileURI
     
*/
    
public void parseXMLFile(String fileURI) {
        
try {
            DocumentBuilderFactory factory 
= DocumentBuilderFactory.newInstance();
            
// 鍏佽鍚嶅瓧絀洪棿
            factory.setNamespaceAware(true);
            
// 鍏佽楠岃瘉
            factory.setValidating(true);
            
// 鑾峰緱DocumentBuilder鐨勪竴涓疄渚?/span>
            DocumentBuilder builder = factory.newDocumentBuilder();
            
// 瑙f瀽鏂囨。錛屽茍鑾峰緱涓涓狣ocument瀹炰緥銆?/span>
            Document doc = builder.parse(fileURI);
            
// 鑾峰緱鏍硅妭鐐筍tuInfo
            Element elmtStuInfo = doc.getDocumentElement();
            
// 寰楀埌鎵鏈塻tudent鑺傜偣
            NodeList nlStudent = elmtStuInfo.getElementsByTagNameNS(strNamespace, "student");
            System.out.println(
"**** Student information start ****");
            
// 寰幆杈撳嚭姣忎竴涓鐢熻祫鏂?/span>
            for (int i = 0; i < nlStudent.getLength(); i++) {
                
// 褰撳墠student鑺傜偣鍏冪礌
                Element elmtStudent = (Element) nlStudent.item(i);
                NodeList nlCurrent 
= elmtStudent.getElementsByTagNameNS(strNamespace, "name");
                System.out.println(
"Name:"+ nlCurrent.item(0).getFirstChild().getNodeValue());
                nlCurrent 
= elmtStudent.getElementsByTagNameNS(strNamespace,"sex");
                System.out.println(
"Sex:"+ nlCurrent.item(0).getFirstChild().getNodeValue());
                nlCurrent 
= elmtStudent.getElementsByTagNameNS(strNamespace,"lesson");
                
for (int j = 0; j < nlCurrent.getLength(); j++) {
                    Element elmtLesson 
= (Element) nlCurrent.item(j);
                    NodeList nlLesson 
= elmtLesson.getElementsByTagNameNS(strNamespace, "lessonName");
                    System.out.print(nlLesson.item(
0).getFirstChild().getNodeValue());
                    System.out.print(
":");
                    nlLesson 
= elmtLesson.getElementsByTagNameNS(strNamespace,"lessonScore");
                    System.out.print(nlLesson.item(
0).getFirstChild().getNodeValue());
                    System.out.print(
"\n");
                }
                System.out.println(
"------------------------------------");
            }
            System.out.println(
"**** Student information end ****");
        } 
catch (SAXException saxe) {
            System.out.println(
"error1");
            System.out.println(saxe.getMessage());
        } 
catch (IOException ioe) {
            System.out.println(
"error2");
            System.out.println(ioe.getMessage());
        } 
catch (ParserConfigurationException pce) {
            System.out.println(
"error3");
            System.out.println(pce.getMessage());
        }
    }
}
杈撳嚭緇撴灉濡備笅錛?br />
**** Student information start ****
Name:bigmouse
Sex:male
math:
60
Englist:
59
autoCAD:
80
SCM:
90
mechanics:
61
------------------------------------
Name:coco
Sex:female
math:
90
Englist:
95
C
++:80
Java:
85
------------------------------------
**** Student information end ****
鍒嗘瀽錛?br /> 1.浠庝笂闈㈠鍏ョ殑鍖呭氨鍙互鐪嬪嚭涓昏搴旂敤錛歫avax.xml.parsers 鍜?org.w3c.dom  榪欎袱涓寘閮芥槸鍩虹鍖咃紝jdk 涓湁銆傚洜姝OM鏂瑰紡涓嶇敤瀵煎叆鍏跺畠鍖呭氨鍙繍琛屻傚張鍙互鐪嬪嚭寰楀埌浜唚3c緇勭粐鐨勮鍙傚叾瀹炶繖涓狣OM 鏂瑰紡榪樼粨鍚堜簡.jaxp 涔熷氨鏄痡ava api for xml parser
2.鏈涓昏鐨勪竴鐐癸紝鏄懡鍚嶇┖闂寸殑浣跨敤錛屾墍鏈夌殑緇撶偣涔熼兘鍦ㄥ湪鍛藉悕絀洪棿涓墍瀹氫箟鐨勩?br /> 3銆傝鍙杧ml浜х敓Document 瀵硅薄銆侼odeList 涓亶鍘嗘墍鐨勭粨鐐廣?br /> 榪欎釜渚嬪瓙灝卞埌榪欓噷錛屼笅涓綃囨槸JDOM鏂規硶銆?br />


]]>
JAVA XML 瑙f瀽涔嬩竴(鍑嗗綃?http://www.tkk7.com/dingdangxiaoma/articles/194537.html鍙綋灝忛┈鍙綋灝忛┈Mon, 21 Apr 2008 08:33:00 GMThttp://www.tkk7.com/dingdangxiaoma/articles/194537.htmlhttp://www.tkk7.com/dingdangxiaoma/comments/194537.htmlhttp://www.tkk7.com/dingdangxiaoma/articles/194537.html#Feedback0http://www.tkk7.com/dingdangxiaoma/comments/commentRss/194537.htmlhttp://www.tkk7.com/dingdangxiaoma/services/trackbacks/194537.html 鍏充簬XML 鍦↗AVA涓殑搴旂敤錛岀浉鍏蟲妧鏈偣DOM 錛孲AX 錛孞DOM 鍙奃OM4j 
璁ㄨ鍙互鍙傝冿細http://java.chinaitlab.com/XMLBeans/717370_2.html
鍙﹀鍙互鍙傝冿細http://www.javaresearch.org/article/1181.htm
榪欎袱緗戝潃錛岄兘鏈塜ML鐨勮В鏋愮殑渚嬪瓙銆傜幇鎶婁粬浠殑渚嬪瓙錛屽疄闄呯殑璺戜簡涓涓嬶紝鍒嗗埆瀵瑰洓縐嶆妧鏈殑渚嬪瓙鎬葷粨濡備笅銆?br /> javaresearch 涓婄殑渚嬪瓙銆?br /> 鍓嶆彁鍑嗗鏂囦歡錛?xml .dtd ,.xsl
SutInfo.xml
<?xml version="1.0"?>
<?xml-stylesheet href="xsl\StuInfo.xsl" type="text/xsl"?>
<!DOCTYPE LIT:StuInfo SYSTEM "dtd\student.dtd">
<LIT:StuInfo xmlns:LIT="http://www.lit.edu.cn/student/">
    
<LIT:student>
        
<LIT:name>bigmouse</LIT:name>
        
<LIT:sex>male</LIT:sex>
        
<LIT:lesson>
            
<LIT:lessonName>math</LIT:lessonName>
            
<LIT:lessonScore>60</LIT:lessonScore>
        
</LIT:lesson>
        
<LIT:lesson>
            
<LIT:lessonName>Englist</LIT:lessonName>
            
<LIT:lessonScore>59</LIT:lessonScore>
        
</LIT:lesson>
        
<LIT:lesson>
            
<LIT:lessonName>autoCAD</LIT:lessonName>
            
<LIT:lessonScore>80</LIT:lessonScore>
        
</LIT:lesson>
        
<LIT:lesson>
            
<LIT:lessonName>SCM</LIT:lessonName>
            
<LIT:lessonScore>90</LIT:lessonScore>
        
</LIT:lesson>
        
<LIT:lesson>
            
<LIT:lessonName>mechanics</LIT:lessonName>
            
<LIT:lessonScore>61</LIT:lessonScore>
        
</LIT:lesson>
    
</LIT:student>
    
<LIT:breakLine />
    
<LIT:student>
        
<LIT:name>coco</LIT:name>
        
<LIT:sex>female</LIT:sex>
        
<LIT:lesson>
            
<LIT:lessonName>math</LIT:lessonName>
            
<LIT:lessonScore>90</LIT:lessonScore>
        
</LIT:lesson>
        
<LIT:lesson>
            
<LIT:lessonName>Englist</LIT:lessonName>
            
<LIT:lessonScore>95</LIT:lessonScore>
        
</LIT:lesson>
        
<LIT:lesson>
            
<LIT:lessonName>C++</LIT:lessonName>
            
<LIT:lessonScore>80</LIT:lessonScore>
        
</LIT:lesson>
        
<LIT:lesson>
            
<LIT:lessonName>Java</LIT:lessonName>
            
<LIT:lessonScore>85</LIT:lessonScore>
        
</LIT:lesson>
    
</LIT:student>
    
<LIT:breakLine />
    
<LIT:master>&masterName;
    
</LIT:master>
</LIT:StuInfo>
榪欎釜xml涓殑鍓嶅嚑琛屼腑錛屾湁xsl鍙?dtd澹版槑銆備竴涓槸鏍峰紡錛屼竴涓槸doctype澹版槑銆?br /> student.dtd
<!ELEMENT LIT:StuInfo ((LIT:student, LIT:breakLine)*, LIT:master)>
<!ATTLIST LIT:StuInfo xmlns:LIT CDATA #REQUIRED>
<!ELEMENT LIT:student (LIT:name, LIT:sex, LIT:lesson*)>
<!ELEMENT LIT:name (#PCDATA)>
<!ELEMENT LIT:sex (#PCDATA)>
<!ELEMENT LIT:lesson (LIT:lessonName, LIT:lessonScore)>
<!ELEMENT LIT:lessonName (#PCDATA)>
<!ELEMENT LIT:lessonScore (#PCDATA)>
<!ELEMENT LIT:breakLine EMPTY>
<!ELEMENT LIT:master (#PCDATA)>
<!ENTITY masterName SYSTEM "master.txt">
StuInfo.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:LIT
="http://www.lit.edu.cn/student/"
        version
="1.0">
    
<xsl:template match="LIT:StuInfo">
        
<html>
            
<head>
                
<title>Student Information</title>
            
</head>
            
<body>
                
<xsl:apply-templates select="*"/>
            
</body>
        
</html>
    
</xsl:template>

    
<xsl:template match="LIT:student">
        
<li>Name:<xsl:value-of select="LIT:name"/></li>
        
<li>Sex:<xsl:value-of select="LIT:sex"/></li>
        
<xsl:for-each select="LIT:lesson">
            
<li>Lesson:<xsl:value-of select="LIT:lessonName"/>(<xsl:value-of select="LIT:lessonScore"/>)</li>
        
</xsl:for-each>
    
</xsl:template>

    
<xsl:template match="LIT:breakLine">
        
<hr/>
    
</xsl:template>

    
<xsl:template match="master">
        
<xsl:copy-of select="*"/>
    
</xsl:template>

</xsl:stylesheet>
涓婇潰灝辨槸鎵鏈夌殑閰嶇疆鏂囦歡浜嗐傝繖浜涙枃浠跺彲鏀懼湪web宸ョ▼鐨勬牴鐩綍涓嬮潰銆備篃鍙互鏀懼湪webRoot/xml/鏂囦歡澶逛笅銆傛垜灝辨槸鏀懼埌榪欎釜鏂囦歡澶逛笅鐨勶紝鑳借繃web鏂瑰紡鏉ヨ闂?xml鏂囦歡鐨勶紝褰撶劧浜嗭紝涔熷彲浠ラ氳繃緇濆璺緞鏉ヨ闂繖涓祫婧愩?br /> 鍦ㄤ笅闈㈢殑紼嬪簭涓紝鍙兘浼氶亣鍒頒笉閰嶇疆涓婇潰鐨勬枃浠訛紝涔熷彲鍦ㄦ帶鍒跺彴涓嬭闂?xml鎵撳嵃鍑虹浉鍏蟲暟鎹殑銆備絾錛屾垜榪樻槸寤鴻浣狅紝鎶婁笂闈td.鍙?xsl鐨勭浉鍏崇煡璇嗗紕鎳備竴浜涖?br /> 榪欎竴綃囧氨浜嗚繖閲岋紝涓嬩竴綃囪瑙?DOM渚嬪瓙銆?br />


]]>
XML 綆鍗曞叆闂ㄤ箣浜?/title><link>http://www.tkk7.com/dingdangxiaoma/articles/194025.html</link><dc:creator>鍙綋灝忛┈</dc:creator><author>鍙綋灝忛┈</author><pubDate>Fri, 18 Apr 2008 06:08:00 GMT</pubDate><guid>http://www.tkk7.com/dingdangxiaoma/articles/194025.html</guid><wfw:comment>http://www.tkk7.com/dingdangxiaoma/comments/194025.html</wfw:comment><comments>http://www.tkk7.com/dingdangxiaoma/articles/194025.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/dingdangxiaoma/comments/commentRss/194025.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/dingdangxiaoma/services/trackbacks/194025.html</trackback:ping><description><![CDATA[2008騫?鏈?8鏃?Edited By DingDangXiaoMa<br /> 鍦╔ML 鐨勫簲鐢ㄦ柟闈紝涔熸病鏈変粈涔堢粡楠岋紝鍦╦ava涓篃搴旂敤浜嗕竴浜涜繃涓浜涢厤緗枃浠訛紝浣嗘病鏈夋帴瑙﹁繃浠涔堝疄璐ㄤ笂鐨勫唴瀹廣?br /> 灝辯敤鏂歸潰鏈夛細SOAP 榪樻湁WebService.<br /> 鏈崟涓粙緇嶄竴浜沇ebService 鏂歸潰鐨勬蹇點?br /> <h2>浠涔堟槸Web Services錛?/h2> <ul> <li>Web Services 鏄簲鐢ㄧ▼搴忕粍浠? </li> <li>Web Services 浣跨敤寮鏀懼崗璁繘琛岄氫俊 </li> <li>Web Services 鏄嫭绔嬬殑錛坰elf-contained錛夊茍鍙嚜鎴戞弿榪? </li> <li>Web Services 鍙氳繃浣跨敤UDDI鏉ュ彂鐜? </li> <li>Web Services 鍙鍏朵粬搴旂敤紼嬪簭浣跨敤 </li> <li>XML 鏄?Web Services 鐨勫熀紜</li> </ul> <p>鍩虹鐨?Web Services 騫沖彴鏄?XML + HTTP銆?/p> <p>HTTP 鍗忚鏄渶甯哥敤鐨勫洜鐗圭綉鍗忚銆?/p> <p>XML 鎻愪緵浜嗕竴縐嶅彲鐢ㄤ簬涓嶅悓鐨勫鉤鍙板拰緙栫▼璇█涔嬮棿鐨勮璦銆?br /> </p> <p>Web services 騫沖彴鐨勫厓绱狅細</p> <ul> <li>SOAP (綆鏄撳璞¤闂崗璁? </li> <li>UDDI (閫氱敤鎻忚堪銆佸彂鐜板強鏁村悎) </li> <li>WSDL (Web services 鎻忚堪璇█)</li> </ul> <br /> <h2>浠涔堟槸 SOAP錛?/h2> <p>鍩烘湰鐨?Web services 騫沖彴鏄?XML + HTTP銆?/p> <ul> <li>SOAP 鎸囩畝鏄撳璞¤闂崗璁? </li> <li>SOAP 鏄竴縐嶉氫俊鍗忚 </li> <li>SOAP 鐢ㄤ簬搴旂敤紼嬪簭涔嬮棿鐨勯氫俊 </li> <li>SOAP 鏄竴縐嶇敤浜庡彂閫佹秷鎭殑鏍煎紡 </li> <li>SOAP 琚璁$敤鏉ラ氳繃鍥犵壒緗戣繘琛岄氫俊 </li> <li>SOAP 鐙珛浜庡鉤鍙? </li> <li>SOAP 鐙珛浜庤璦 </li> <li>SOAP 鍩轟簬 XML </li> <li>SOAP 寰堢畝鍗曞茍鍙墿灞? </li> <li>SOAP 鍏佽鎮ㄧ粫榪囬槻鐏 </li> <li>SOAP 灝嗕綔涓?W3C 鏍囧噯鏉ュ彂</li> </ul> <br /> <h2>浠涔堟槸 WSDL?</h2> <p>WSDL 鏄熀浜?XML 鐨勭敤浜庢弿榪?Web Services 浠ュ強濡備綍璁塊棶 Web Services 鐨勮璦銆?/p> <ul> <li>WSDL 鎸囩綉緇滄湇鍔℃弿榪拌璦 </li> <li>WSDL 浣跨敤 XML 緙栧啓 </li> <li>WSDL 鏄竴縐?XML 鏂囨。 </li> <li>WSDL 鐢ㄤ簬鎻忚堪緗戠粶鏈嶅姟 </li> <li>WSDL 涔熷彲鐢ㄤ簬瀹氫綅緗戠粶鏈嶅姟 </li> <li>WSDL 榪樹笉鏄?W3C 鏍?/li> </ul> <br /> <h2>浠涔堟槸UDDI錛?/h2> <p>UDDI 鏄竴縐嶇洰褰曟湇鍔★紝閫氳繃瀹冿紝浼佷笟鍙敞鍐屽茍鎼滅儲 Web services銆?/p> <ul> <li>UDDI 鎸囬氱敤鐨勬弿榪般佸彂鐜頒互鍙婃暣鍚堬紙Universal Description, Discovery and Integration錛夈? </li> <li>UDDI 鏄竴縐嶇敤浜庡瓨鍌ㄦ湁鍏?web services 鐨勪俊鎭殑鐩綍銆? </li> <li>UDDI 鏄竴縐嶇敱 WSDL 鎻忚堪鐨勭綉緇滄湇鍔℃帴鍙g洰褰曘? </li> <li>UDDI 緇忕敱 SOAP 榪涜閫氳繀銆? </li> <li>UDDI 琚瀯寤轟簬 Microsoft .NET 騫沖彴涔嬩腑</li> </ul> 涓婅堪璁茶В浜哤ebService鐨勭粍鎴愬厓绱狅紝鍏蜂綋鐨勫簲鐢ㄦ湁  axis 鎴杧fire 絳夈傛湁鏈轟細鐨勮瘽錛屽啀璇翠竴璇達紝xml鍦╦ava鐨勫簲鐢ㄣ?br /> <br /> <img src ="http://www.tkk7.com/dingdangxiaoma/aggbug/194025.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/dingdangxiaoma/" target="_blank">鍙綋灝忛┈</a> 2008-04-18 14:08 <a href="http://www.tkk7.com/dingdangxiaoma/articles/194025.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>XML 綆鍗曞叆闂?/title><link>http://www.tkk7.com/dingdangxiaoma/articles/194020.html</link><dc:creator>鍙綋灝忛┈</dc:creator><author>鍙綋灝忛┈</author><pubDate>Fri, 18 Apr 2008 05:53:00 GMT</pubDate><guid>http://www.tkk7.com/dingdangxiaoma/articles/194020.html</guid><wfw:comment>http://www.tkk7.com/dingdangxiaoma/comments/194020.html</wfw:comment><comments>http://www.tkk7.com/dingdangxiaoma/articles/194020.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/dingdangxiaoma/comments/commentRss/194020.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/dingdangxiaoma/services/trackbacks/194020.html</trackback:ping><description><![CDATA[2008騫?鏈?8鏃?13:29:06 Edited By DingDangXiaoMa<br /> W3school xml鍩虹鐭ヨ瘑錛?nbsp; <a title="http://www.w3school.com.cn/x.asp" >http://www.w3school.com.cn/x.asp</a><br /> 榪欏崟浠嬬粛綆鍗曠殑XML 鍙奨SL 絳夈?br /> 浠涔堟槸XML,XSL,瀹冧滑鏈変粈涔堜綔鐢ㄤ笌HTML鐨勫尯鍒垨鏈変粈涔堣仈緋匯傚甫鐫榪欎簺闂錛屾垜浠紑濮媥ml涔嬫梾<br /> XML 琚璁$敤鏉ユ弿榪版暟鎹紝鍏剁劍鐐規槸鏁版嵁鐨勫唴瀹廣?span style="font-family: 瀹嬩綋;"> <p>HTML 琚璁$敤鏉ユ樉紺烘暟鎹紝鍏剁劍鐐規槸鏁版嵁鐨勫瑙?</p> </span> <h2>浠涔堟槸XML?</h2> <ul> <li>XML 鎸?em>鍙墿灞曟爣璁拌璦</em>錛圗Xtensible Markup Language錛? </li> <li>XML 鏄竴縐?em>鏍囪璇█</em>錛屽緢綾諱技 HTML </li> <li>XML 琚璁$敤鏉?em>鎻忚堪鏁版嵁</em> </li> <li>XML 鏍囩娌℃湁琚瀹氫箟銆傛偍闇瑕?em>鑷瀹氫箟鏍囩</em>銆? </li> <li>XML 浣跨敤<em>鏂囦歡綾誨瀷澹版槑</em>錛圖TD錛夋垨鑰?<em>XML Schema</em> 鏉ユ弿榪版暟鎹? </li> <li>甯︽湁 DTD 鎴栬?XML Schema 鐨?XML 琚璁′負鍏鋒湁<em>鑷垜鎻忚堪鎬?/em>銆? </li> <li>XML 鏄竴涓?W3C 鏍囧噯</li> </ul> <h2>XML 涓?HTML 鐨勪富瑕佸樊寮?/h2> <p>XML 琚璁$敤鏉ユ惡甯︽暟鎹?/p> <p>XML 涓嶆槸鐢ㄦ潵鏇夸唬 HTML 鐨勩?/p> <p>XML 鍜?HTML 涓轟笉鍚岀殑鐩殑鑰岃璁★細</p> <p>XML 琚璁$敤鏉ユ弿榪版暟鎹紝鍏剁劍鐐規槸鏁版嵁鐨勫唴瀹廣?/p> <p>HTML 琚璁$敤鏉ユ樉紺烘暟鎹紝鍏剁劍鐐規槸鏁版嵁鐨勫瑙傘?/p> <p>HTML 鏃ㄥ湪鏄劇ず淇℃伅錛岃?XML 鏃ㄥ湪鎻忚堪淇℃伅</p> <br /> <h2>XML 鏄 HTML 鐨勮ˉ鍏?/h2> <p>XML 涓嶆槸 HTML 鐨勬浛浠g墿</p> <p>鎮ㄩ渶瑕佺悊瑙?XML 涓嶆槸 HTML 鐨勬浛浠g墿錛岃繖涓鐐歸潪甯擱噸瑕併傚湪鏈潵鐨?Web 寮鍙戜腑錛屾渶鏈夊彲鑳藉嚭鐜扮殑鎯呭喌鏄紝XML 浼氳鐢ㄦ潵鎻忚堪鏁版嵁錛岃?HTML 浼氳鐢ㄦ潵鏍煎紡鍖栧拰鏄劇ず榪欎簺鏁版嵁銆?/p> <p>鎴戜滑鍏充簬 XML 鏈濂界殑鎻忚堪鏄細XML 鏄法騫沖彴鐨勩佺敤浜庝紶杈撲俊鎭笖鐙珛浜庤蔣浠跺拰紜歡鐨勫伐鍏?/p> <p>鍦╔ML鐨勫熀紜涔嬩笂錛屽氨鏄XML鐨勫簲鐢ㄣ?/p> <p>XSL :鎸囨墿灞曟牱寮忚〃璇█涓伙紝XSLT 鎸嘪SL 杞崲銆?br /> </p> <p>XPath 鏄竴闂ㄥ湪XML 鏂囨。涓煡鎵句綇澶勭殑璇█銆傚彲浠ュ鍏冪礌錛屽睘鎬ц繘琛岄亶鍘嗐?/p> <p>XLink 瀹氫箟鍦╔ML鏂囨。涓垱寤鴻秴綰ч摼鎺ョ殑鏍囧噯鏂規硶銆?/p> <p>DTD 錛堟枃妗e畾涔夌被鍨嬶級 瀹氫箟XML鏂囨。鐨勪漸鏋勫緩妯″潡銆?/p> <p>XML Schema  鏄熀浜?XML 鐨凞TD 鏇夸唬鍝侊紝鎻忚堪XML 鏂囨。鐨勭粨鏋勩?/p> <p>絳変竴浜涘熀鏈殑姒傚康錛屽彲浠ユ煡闃呭畼鏂圭殑璧勬枡銆?/p> <img src ="http://www.tkk7.com/dingdangxiaoma/aggbug/194020.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/dingdangxiaoma/" target="_blank">鍙綋灝忛┈</a> 2008-04-18 13:53 <a href="http://www.tkk7.com/dingdangxiaoma/articles/194020.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://wwwv27.com" target="_blank">中字幕视频在线永久在线观看免费 </a>| <a href="http://dstbxg.com" target="_blank">在线看片免费不卡人成视频</a>| <a href="http://spxingyiquan.com" target="_blank">91手机看片国产永久免费</a>| <a href="http://zp0533.com" target="_blank">久久WWW色情成人免费观看</a>| <a href="http://qihongxia.com" target="_blank">国产免费私拍一区二区三区</a>| <a href="http://1314xxx.com" target="_blank">国产L精品国产亚洲区久久</a>| <a href="http://zgxxx.com" target="_blank">亚洲电影免费在线观看</a>| <a href="http://tianmao920.com" target="_blank">avtt天堂网手机版亚洲</a>| <a href="http://zzhjnmzp.com" target="_blank">污污的视频在线免费观看</a>| <a href="http://126cm.com" target="_blank">久久美女网站免费</a>| <a href="http://www65axax.com" target="_blank">黄色成人网站免费无码av</a>| <a href="http://367316.com" target="_blank">亚洲av成人一区二区三区在线观看</a>| <a href="http://ddm88888.com" target="_blank">亚洲香蕉网久久综合影视</a>| <a href="http://quxx28.com" target="_blank">亚洲精品国产第1页</a>| <a href="http://plladay.com" target="_blank">色天使色婷婷在线影院亚洲</a>| <a href="http://600c63.com" target="_blank">中文字幕无码一区二区免费</a>| <a href="http://igo98.com" target="_blank">国拍在线精品视频免费观看</a>| <a href="http://zhuguangbaoyu.com" target="_blank">免费va人成视频网站全</a>| <a href="http://airou08.com" target="_blank">久久91亚洲精品中文字幕</a>| <a href="http://wwwhaole10.com" target="_blank">国产精品亚洲精品观看不卡</a>| <a href="http://zdmaid.com" target="_blank">一级毛片免费播放视频</a>| <a href="http://muguangmi.com" target="_blank">亚洲一区二区三区免费在线观看</a>| <a href="http://ge2hao.com" target="_blank">免费大黄网站在线观</a>| <a href="http://jxgsgg.com" target="_blank">亚洲视频在线观看免费</a>| <a href="http://998wc.com" target="_blank">最新亚洲人成网站在线观看 </a>| <a href="http://www456788.com" target="_blank">91高清免费国产自产</a>| <a href="http://www-79983.com" target="_blank">国产美女被遭强高潮免费网站</a>| <a href="http://14743592.com" target="_blank">亚洲精品亚洲人成在线观看</a>| <a href="http://bz600.com" target="_blank">亚洲精品一二三区</a>| <a href="http://gysysz.com" target="_blank">成人免费一区二区三区</a>| <a href="http://1314c.com" target="_blank">免费看国产成年无码AV片</a>| <a href="http://ittenyear.com" target="_blank">日韩亚洲变态另类中文</a>| <a href="http://18eeuus.com" target="_blank">99亚偷拍自图区亚洲</a>| <a href="http://www-715111.com" target="_blank">最新久久免费视频</a>| <a href="http://zhaoxinwo.com" target="_blank">永久免费av无码网站大全</a>| <a href="http://166sb.com" target="_blank">亚洲乱亚洲乱淫久久</a>| <a href="http://cg-fun.com" target="_blank">另类图片亚洲校园小说区</a>| <a href="http://avyjj.com" target="_blank">国产成人精品久久免费动漫 </a>| <a href="http://kingco-glaze.com" target="_blank">国产资源免费观看</a>| <a href="http://jdvgo.com" target="_blank">久久精品九九亚洲精品</a>| <a href="http://newbuybay.com" target="_blank">高清免费久久午夜精品</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>