锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产成+人+综合+亚洲专,亚洲变态另类一区二区三区,亚洲男人天堂2020http://www.tkk7.com/Good-Game/category/24758.htmlzh-cnThu, 29 May 2008 08:45:38 GMTThu, 29 May 2008 08:45:38 GMT60xquery 瀛︿範 (綆鍗昫emo)http://www.tkk7.com/Good-Game/archive/2008/05/29/203834.htmlG_GG_GThu, 29 May 2008 06:49:00 GMThttp://www.tkk7.com/Good-Game/archive/2008/05/29/203834.htmlhttp://www.tkk7.com/Good-Game/comments/203834.htmlhttp://www.tkk7.com/Good-Game/archive/2008/05/29/203834.html#Feedback0http://www.tkk7.com/Good-Game/comments/commentRss/203834.htmlhttp://www.tkk7.com/Good-Game/services/trackbacks/203834.html鐜:
聽聽聽 1.xml鏁版嵁搴撲嬌鐢?img title="eXist" src="http://demo.exist-db.org/logo.jpg" height="35" width="90" />錛堝弬鑰冿細eXistQuick Start錛?br />聽聽聽 2.xQuery XQuery 棣栭〉
聽聽聽
1.嫻嬭瘯寮濮嬶細
聽聽聽 榪涘叆錛歟Xist-> http://demo.exist-db.org/xmldb/db/聽
for $x in doc("/examples2.xml")/exist:result/country return if ($x/population_growth<-1) then <child>{data($x/name)}</child> else <adult>{data($x/name)}</adult>
parent collection: /db
<child > Bosnia and Herzegovina </ child >
<adult > Czech Republic </ adult >
<child > Estonia </ child >
<child > Faroe Islands </ child >
<adult > Hungary </ adult >
<adult > Ireland </ adult >
<child > Latvia </ child >
<adult > Lithuania </ adult >
<child > Romania </ child >
<adult > Russia </ adult >

浣跨敤鏁版嵁錛?br />聽聽聽 http://demo.exist-db.org/xmldb/db/examples2.xml


2錛氳嚜瀹氫箟鏂規硶錛?br />聽聽聽 浣跨敤錛歨ttp://demo.exist-db.org/sandbox/sandbox.xql
聽聽聽
declarefunction聽local:minPrice(){
聽聽
for聽$x聽in聽(1to5)
聽聽
return<test>{$x}</test>
};

<minPrice>{local:minPrice()}</minPrice>
緇撴灉錛?br /><minPrice>
<test>1</test>
<test>2</test>
<test>3</test>
<test>4</test>
<test>5</test>
</minPrice>






G_G 2008-05-29 14:49 鍙戣〃璇勮
]]>
xml -> xls 綆鍗曟牸寮?/title><link>http://www.tkk7.com/Good-Game/archive/2007/11/28/163765.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Wed, 28 Nov 2007 10:13:00 GMT</pubDate><guid>http://www.tkk7.com/Good-Game/archive/2007/11/28/163765.html</guid><wfw:comment>http://www.tkk7.com/Good-Game/comments/163765.html</wfw:comment><comments>http://www.tkk7.com/Good-Game/archive/2007/11/28/163765.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/Good-Game/comments/commentRss/163765.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/Good-Game/services/trackbacks/163765.html</trackback:ping><description><![CDATA[ <br />test.xls 涓唴瀹?-><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);"><?</span><span style="color: rgb(255, 0, 255);">xml聽version="1.0"</span><span style="color: rgb(0, 0, 255);">?></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Workbook聽</span><span style="color: rgb(255, 0, 0);">xmlns</span><span style="color: rgb(0, 0, 255);">="urn:schemas-microsoft-com:office:spreadsheet"</span><span style="color: rgb(255, 0, 0);"><br />xmlns:o</span><span style="color: rgb(0, 0, 255);">="urn:schemas-microsoft-com:office:office"</span><span style="color: rgb(255, 0, 0);"><br />xmlns:x</span><span style="color: rgb(0, 0, 255);">="urn:schemas-microsoft-com:office:excel"</span><span style="color: rgb(255, 0, 0);"><br />xmlns:ss</span><span style="color: rgb(0, 0, 255);">="urn:schemas-microsoft-com:office:spreadsheet"</span><span style="color: rgb(255, 0, 0);"><br />xmlns:html</span><span style="color: rgb(0, 0, 255);">="http://www.w3.org/TR/REC-html40"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Worksheet聽</span><span style="color: rgb(255, 0, 0);">ss:Name</span><span style="color: rgb(0, 0, 255);">="xls1"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /><br />聽</span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Table</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br />聽聽</span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br />聽聽聽</span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Cell</span><span style="color: rgb(0, 0, 255);">><</span><span style="color: rgb(128, 0, 0);">Data聽</span><span style="color: rgb(255, 0, 0);">ss:Type</span><span style="color: rgb(0, 0, 255);">="String"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">cell聽a1</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Data</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">Cell</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br />聽聽聽</span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Cell</span><span style="color: rgb(0, 0, 255);">><</span><span style="color: rgb(128, 0, 0);">Data聽</span><span style="color: rgb(255, 0, 0);">ss:Type</span><span style="color: rgb(0, 0, 255);">="String"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">cell聽b2</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Data</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">Cell</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br />聽聽</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br />聽聽</span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br />聽聽聽</span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Cell</span><span style="color: rgb(0, 0, 255);">><</span><span style="color: rgb(128, 0, 0);">Data聽</span><span style="color: rgb(255, 0, 0);">ss:Type</span><span style="color: rgb(0, 0, 255);">="String"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">cell聽a2</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Data</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">Cell</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br />聽聽聽</span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">Cell</span><span style="color: rgb(0, 0, 255);">><</span><span style="color: rgb(128, 0, 0);">Data聽</span><span style="color: rgb(255, 0, 0);">ss:Type</span><span style="color: rgb(0, 0, 255);">="String"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">cell聽b3</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Data</span><span style="color: rgb(0, 0, 255);">></</span><span style="color: rgb(128, 0, 0);">Cell</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br />聽聽</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br />聽</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Table</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Worksheet</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">Workbook</span><span style="color: rgb(0, 0, 255);">></span></div><br /><br />灞曠幇鐨勬牱瀛?><br /><table x:str="" style="border-collapse: collapse; width: 108pt;" border="0" cellpadding="0" cellspacing="0" width="144"><col style="width: 54pt;" span="2" width="72" /><tbody><tr style="height: 14.25pt;" height="19"><td style="height: 14.25pt; width: 54pt;" height="19" width="72">cell a1</td><td style="width: 54pt;" width="72">cell b2</td></tr><tr style="height: 14.25pt;" height="19"><td style="height: 14.25pt;" height="19">cell a2</td><td>cell b3</td></tr></tbody></table><br /><img src ="http://www.tkk7.com/Good-Game/aggbug/163765.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/Good-Game/" target="_blank">G_G</a> 2007-11-28 18:13 <a href="http://www.tkk7.com/Good-Game/archive/2007/11/28/163765.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>dom4j 瀛︿範http://www.tkk7.com/Good-Game/archive/2007/11/06/158565.htmlG_GG_GTue, 06 Nov 2007 07:24:00 GMThttp://www.tkk7.com/Good-Game/archive/2007/11/06/158565.htmlhttp://www.tkk7.com/Good-Game/comments/158565.htmlhttp://www.tkk7.com/Good-Game/archive/2007/11/06/158565.html#Feedback6http://www.tkk7.com/Good-Game/comments/commentRss/158565.htmlhttp://www.tkk7.com/Good-Game/services/trackbacks/158565.htmldom4j 鐨勪竴鑸嬌鐢ㄩ兘鍦ㄩ噷闈簡
/lib/dom4j-1.6.1.jar
/lib/jaxen-1.1-beta-6.jar
package聽useDom4j.test.supper;

import聽java.io.File;
import聽java.io.FileOutputStream;
import聽java.io.IOException;
import聽java.io.InputStream;
import聽java.io.OutputStream;
import聽java.net.URL;
import聽java.util.Iterator;
import聽java.util.List;
import聽java.util.regex.Matcher;
import聽java.util.regex.Pattern;

import聽javax.xml.parsers.DocumentBuilder;
import聽javax.xml.parsers.DocumentBuilderFactory;

import聽junit.framework.TestCase;

import聽org.dom4j.Document;
import聽org.dom4j.DocumentFactory;
import聽org.dom4j.DocumentHelper;
import聽org.dom4j.Element;
import聽org.dom4j.Node;
import聽org.dom4j.QName;
import聽org.dom4j.Visitor;
import聽org.dom4j.VisitorSupport;
import聽org.dom4j.XPath;
import聽org.dom4j.io.DOMReader;
import聽org.dom4j.io.HTMLWriter;
import聽org.dom4j.io.OutputFormat;
import聽org.dom4j.io.SAXReader;
import聽org.dom4j.io.XMLWriter;


publicclass聽useDom4jTest聽extends聽TestCase聽{

聽聽聽聽
//use聽all
聽聽聽聽private聽String聽path聽;
聽聽聽聽
private聽ClassLoader聽clo;
聽聽聽聽
//聽file聽path聽->聽bin聽
聽聽聽聽private聽String聽classPath聽;
聽聽聽聽
//use聽save聽
聽聽聽聽staticprivate聽Document聽doc;
聽聽聽聽
private聽String聽filese;

聽聽聽聽
protectedvoid聽setUp()聽throws聽Exception聽{
聽聽聽聽聽聽聽聽
super.setUp();
聽聽聽聽聽聽聽聽path聽
="useDom4j/test/config/test.xml";
聽聽聽聽聽聽聽聽clo聽
=this.getClass().getClassLoader();
聽聽聽聽聽聽聽聽classPath聽
=聽System.getProperty("java.class.path").split(";")[0]聽聽聽;
聽聽聽聽聽聽聽聽filese聽
=聽System.getProperty("file.separator");
聽聽聽聽}

聽聽聽聽
protectedvoid聽tearDown()聽throws聽Exception聽{
聽聽聽聽聽聽聽聽
super.tearDown();
聽聽聽聽}

聽聽聽聽
聽聽聽聽
publicvoid聽testRead()throws聽Exception{
聽聽聽聽聽聽聽聽SAXReader聽sax聽
=new聽SAXReader();
聽聽聽聽聽聽聽聽
//File聽read
聽聽聽聽聽聽聽聽Document聽docF聽=聽聽sax.read(
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
new聽File(clo.getResource(path).getFile())
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽);
聽聽聽聽聽聽聽聽assertNotNull(
"is聽File聽saxReader聽err",docF);
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
//InPutStream聽read聽
聽聽聽聽聽聽聽聽Document聽docI聽=聽sax.read(聽clo.getResourceAsStream(path)聽);
聽聽聽聽聽聽聽聽assertNotNull(
"is聽InPutStream聽saxReader聽err",docI);
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
//URL聽read聽
聽聽聽聽聽聽聽聽Document聽docU聽=聽sax.read(聽clo.getResource(path)聽);
聽聽聽聽聽聽聽聽assertNotNull(
"is聽Url聽saxReader聽err",docU);
聽聽聽聽聽聽聽聽
聽聽聽聽}
聽聽聽聽
聽聽聽聽
/**聽converts聽a聽W3C聽DOM聽document聽into聽a聽dom4j聽document聽*/
聽聽聽聽
publicvoid聽testConversion()聽throws聽Exception{
聽聽聽聽聽聽聽聽聽聽DocumentBuilderFactory聽domfac
=DocumentBuilderFactory.newInstance();
聽聽聽聽聽聽聽聽聽聽DocumentBuilder聽dombuilder
=domfac.newDocumentBuilder();
聽聽聽聽聽聽聽聽聽聽InputStream聽input聽
=聽聽clo.getResourceAsStream(path)聽;
聽聽聽聽聽聽聽聽聽聽org.w3c.dom.Document聽doc3c聽
=聽dombuilder.parse(聽input聽);
聽聽聽聽聽聽聽聽聽聽DOMReader聽xmlReader聽
=new聽DOMReader();
聽聽聽聽聽聽聽聽聽聽assertEquals(聽
"聽Conversion聽:聽W3C聽DOM->聽dom4j聽DOM聽err",
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽xmlReader.read(doc3c)聽
instanceof聽Document,true聽);
聽聽聽聽聽聽}
聽聽聽聽聽聽
聽聽聽聽
publicvoid聽testCreate()throws聽Exception{
聽聽聽聽聽聽聽聽聽聽DocumentFactory聽factory聽
=聽DocumentFactory.getInstance();
聽聽聽聽聽聽聽聽聽聽doc聽
=聽factory.createDocument();
聽聽聽聽聽聽聽聽
//root聽Create
聽聽聽聽聽聽聽聽聽聽Element聽root聽=聽doc.addElement("testElement");
聽聽聽聽聽聽聽聽聽聽assertNotNull(
"is聽root聽Create聽err",root);
聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽Element聽author2聽
=聽root.addElement(聽"author"聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽.addAttribute(聽
"name",聽"Toby"聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽.addAttribute(聽
"location",聽"Germany"聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽.addText(聽
"Tobias聽Rademacher"聽);

聽聽聽聽聽聽聽聽聽聽聽聽Element聽author1聽
=聽root.addElement(聽"author"聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽.addAttribute(聽
"name",聽"James"聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽.addAttribute(聽
"location",聽"UK"聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽.addText(聽
"James聽Strachan"聽);
聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽
//Test聽Create聽
聽聽聽聽聽聽聽聽聽聽聽聽
//use聽XPath聽->jaxen-xxx.jar聽聽
聽聽聽聽聽聽聽聽聽聽聽聽assertEquals("create聽Element聽author2聽err",
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽doc.selectSingleNode(
"/testElement/author[@name='Toby']").getText()
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽,
"Tobias聽Rademacher");
聽聽聽聽聽聽聽聽聽聽聽聽assertEquals(
"create聽Element聽author1聽err",
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽doc.selectSingleNode(
"/testElement/author[@location='UK']/@name").getText()
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽,
"James");
聽聽聽聽}



聽聽聽聽聽
publicvoid聽testPrintingHTML()throws聽Exception{
聽聽聽聽聽聽聽聽聽聽聽String聽testSaveXml聽
="useDom4j/test/config/testHtml.html";
聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽testSaveXml聽
=聽classPath+filese+testSaveXml;
聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽File聽file聽
=聽getFile(testSaveXml);
聽聽聽聽聽聽聽聽聽聽聽
//Save聽file.html聽
聽聽聽聽聽聽聽聽聽聽聽HTMLWriter聽writer聽=new聽HTMLWriter(new聽FileOutputStream(聽file聽));
聽聽聽聽聽聽聽聽聽聽聽writer.write(
new聽SAXReader().read(聽clo.getResource(path)聽));
聽聽聽聽聽聽聽聽聽聽聽writer.flush();
聽聽聽聽聽}
聽聽聽聽
聽聽聽聽
publicvoid聽testIterator(){
聽聽聽聽聽聽聽聽Element聽root聽
=this.doc.getRootElement();
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
//Iterator
聽聽聽聽聽聽聽聽Iterator聽elementIterator聽=聽root.elementIterator();
聽聽聽聽聽聽聽聽
while(elementIterator.hasNext()){
聽聽聽聽聽聽聽聽聽聽Element聽element聽
=聽(Element)elementIterator.next();
聽聽聽聽聽聽聽聽聽聽assertNotNull(
"not聽attr聽name",聽element.selectSingleNode("./@name")聽);
聽聽聽聽聽聽聽聽聽聽assertNotNull(
"not聽attr聽location",聽element.selectSingleNode("./@location")聽);
聽聽聽聽聽聽聽聽聽聽assertNotNull(
"not聽Text聽",聽element.selectSingleNode(".").getText()聽);
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
//for聽->聽./XX
聽聽聽聽聽聽聽聽for聽(聽int聽i聽=0,聽size聽=聽root.nodeCount();聽i聽<聽size;聽i++聽)聽{
聽聽聽聽聽聽聽聽聽聽聽聽Node聽node聽
=聽root.node(i);
聽聽聽聽聽聽聽聽聽聽聽聽
if聽(聽node聽instanceof聽Element聽)聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽Element聽element聽
=聽(Element)node;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽assertNotNull(
"not聽attr聽name",聽element.selectSingleNode("./@name")聽);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽assertNotNull(
"not聽attr聽location",聽element.selectSingleNode("./@location")聽);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽assertNotNull(
"not聽Text聽",聽element.selectSingleNode(".").getText()聽);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
//List聽
聽聽聽聽聽聽聽聽List聽elements聽=聽root.elements();
聽聽聽聽聽聽聽聽
int聽size聽=聽elements.size()聽;
聽聽聽聽聽聽聽聽
if聽(聽size聽>4聽)聽{
聽聽聽聽聽聽聽聽聽聽elements.subList(聽
3,聽4聽).clear();
聽聽聽聽聽聽聽聽聽聽assertEquals(
"List聽is聽not聽clear",size-elements.size()==1,true);
聽聽聽聽聽聽聽聽}

聽聽聽聽}
聽聽聽聽
聽聽聽聽
/**聽use聽test.xml聽test
聽聽聽聽聽聽聽聽聽xpath聽->聽/project/organization/
聽聽聽聽聽聽聽聽聽<organization>
聽聽聽聽聽聽聽聽聽聽聽聽聽<name>MetaStuff聽Ltd.</name>
聽聽聽聽聽聽聽聽聽聽聽聽聽<url>
http://sourceforge.net/projects/dom4j</url>
聽聽聽聽聽聽聽聽聽聽聽聽聽<logo>
http://sourceforge.net/sflogo.php?group_id=16035</logo>
聽聽聽聽聽聽聽聽聽聽</organization>聽
聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽xpath聽->聽/project/dependencies/dependency[groupId='msv']
聽聽聽聽聽聽聽聽聽聽聽聽<dependency>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽<groupId>msv</groupId>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽<artifactId>xsdlib</artifactId>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽<version>20030807</version>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽<url>
https://msv.dev.java.net/</url>
聽聽聽聽聽聽聽聽聽聽聽聽</dependency>
聽聽聽聽
*/
聽聽聽聽
publicvoid聽testXpath()throws聽Exception{
聽聽聽聽聽聽聽聽XPath聽xpathSelector聽
=聽DocumentHelper.createXPath("/project/organization/*");
聽聽聽聽聽聽聽聽Document聽docT聽
=new聽SAXReader().read(聽clo.getResourceAsStream(path)聽);
聽聽聽聽聽聽聽聽List聽results聽
=聽xpathSelector.selectNodes(docT);
聽聽聽聽聽聽聽聽
for聽(聽Iterator聽iter聽=聽results.iterator();聽iter.hasNext();聽)聽{
聽聽聽聽聽聽聽聽聽聽Element聽element聽
=聽(Element)聽iter.next();
聽聽聽聽聽聽聽聽聽聽
if(element.getName().equals("name")){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽assertEquals(
"name聽err",聽element.getText().equals("MetaStuff聽Ltd."),true);
聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽
if(element.getName().equals("url")){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽assertEquals(
"url聽err",聽element.getText().equals("http://sourceforge.net/projects/dom4j"),true);
聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽
if(element.getName().equals("logo")){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽assertEquals(
"logo聽err",聽element.getText().equals("http://sourceforge.net/sflogo.php?group_id=16035"),true);
聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
//聽select聽
聽聽聽聽聽聽聽聽String聽url聽=聽docT.valueOf(聽"/project/dependencies/dependency[groupId='msv']/url"聽);
聽聽聽聽聽聽聽聽assertEquals(
"Url聽err",聽url.equals("https://msv.dev.java.net/"),true);
聽聽聽聽聽聽聽聽Number聽count聽
=聽docT.numberValueOf(聽"/project/dependencies/dependency[groupId='msv']/version"聽);
聽聽聽聽聽聽聽聽assertEquals(
"Url聽err",聽count.intValue()==20030807,true);
聽聽聽聽聽聽聽聽
聽聽聽聽}

聽聽聽聽
聽聽聽聽
publicvoid聽testVisitor(){
聽聽聽聽聽聽聽聽Visitor聽visitor聽
=new聽VisitorSupport()聽{
聽聽聽聽聽聽聽聽聽聽聽聽
publicvoid聽visit(Element聽element)聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
"Entity聽name:聽"+聽element.getName()聽聽+"聽text聽:"+聽element.getText()
聽聽聽聽聽聽聽聽聽聽聽聽聽聽);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽};

聽聽聽聽聽聽聽聽聽聽doc.accept(聽visitor聽);
聽聽聽聽}

聽聽聽聽
//聽聽element.clone聽;聽聽element.createCopy聽;聽聽聽
聽聽聽聽publicvoid聽testInsertElementAt()聽throws聽Exception{
聽聽聽聽聽聽聽聽Element聽root聽
=this.doc.getRootElement();
聽聽聽聽聽聽聽聽Element聽oldElement聽
=聽(Element)doc.selectSingleNode("/testElement/author[@name='Toby']");
聽聽聽聽聽聽聽聽Element聽newElement聽
=聽(Element)聽oldElement.clone();
聽聽聽聽聽聽聽聽List聽list聽
=聽root.content();
聽聽聽聽聽聽聽聽list.add(聽root.indexOf(oldElement)
+1,newElement聽);

聽聽聽聽聽}
聽聽聽聽
聽聽聽聽
聽聽聽聽
聽聽聽聽
聽聽聽聽聽
publicvoid聽testSave()throws聽Exception{
聽聽聽聽聽聽聽聽聽聽聽String聽testSaveXml聽
="useDom4j/test/config/testSave.xml";
聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽testSaveXml聽
=聽classPath+filese+testSaveXml;
聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽File聽file聽
=聽getFile(testSaveXml);
聽聽聽聽聽聽聽聽聽聽聽
//Save聽file.xml聽
聽聽聽聽聽聽聽聽聽聽聽XMLWriter聽writer聽=new聽XMLWriter(new聽FileOutputStream(聽file聽));
聽聽聽聽聽聽聽聽聽聽聽writer.write(doc);
聽聽聽聽聽聽聽聽聽聽聽writer.flush();
聽聽聽聽聽}

聽聽聽聽聽
聽聽聽聽聽
聽聽聽聽
private聽File聽getFile(String聽testSaveXml)聽throws聽IOException聽{
聽聽聽聽聽聽聽聽File聽file聽
=null聽;
聽聽聽聽聽聽聽聽聽聽聽URL聽url聽
=聽clo.getResource(testSaveXml);
聽聽聽聽聽聽聽聽聽聽聽
if(url==null){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽file聽
=new聽File(testSaveXml);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽file.createNewFile();
聽聽聽聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽file聽
=new聽File(聽聽url.getFile()聽);
聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
return聽file;
聽聽聽聽}
聽聽聽聽
聽聽聽聽
}

寮曠敤錛歨ttp://freezingxu.blog.com.cn/archives/2006/1892647.shtml
/**
聽聽*聽瀵規寚瀹氱殑鑺傜偣澧炲姞灞炴у拰鏂囨湰
聽聽*聽
@param聽elmt
聽聽*聽
@param聽name
聽聽*聽
@param聽value
聽聽*聽
@param聽text
聽聽*聽
@return
聽聽
*/
public聽Element聽addAttribute(Element聽elmt,String聽name,String聽value){
聽聽elmt.addAttribute(name,value);
聽聽
return聽elmt;
聽}

/**
聽聽*聽淇敼鎸囧畾鑺傜偣鐨勫睘鎬у拰鏂囨湰
聽聽*聽
@param聽elmt
聽聽*聽
@param聽name
聽聽*聽
@param聽value
聽聽*聽
@param聽text
聽聽*聽
@return
聽聽
*/
public聽Element聽setAttribute(Element聽elmt,String聽name,String聽value){
聽聽Attribute聽attribute聽
=聽elmt.attribute(name);
聽聽
//attribute.setName(name);
聽聽attribute.setValue(value);
聽聽List聽list聽
=new聽ArrayList();
聽聽list.add(attribute);
聽聽elmt.setAttributes(list);
聽聽
return聽elmt;
聽}

/**
聽聽*聽鍒犻櫎鎸囧畾鑺傜偣鐨勬寚瀹氬睘鎬?br />聽聽*聽
@param聽elmt
聽聽*聽
@param聽name
聽聽*聽
@return
聽聽
*/
public聽Element聽removeAttribute(Element聽elmt,String聽name){
聽聽elmt.remove(elmt.attribute(name));
聽聽
return聽elmt;
聽}

/**
聽聽*聽杈撳嚭涓烘枃浠?br />聽聽*聽
@param聽doc
聽聽*聽
@throws聽IOException
聽聽
*/
publicvoid聽writeFile(Document聽doc)聽throws聽IOException{
聽聽FileWriter聽out聽
=new聽FileWriter(聽"d:/newQuery.xml"聽);
聽聽doc.write(out);
聽聽out.flush();
聽聽out.close();
聽}



G_G 2007-11-06 15:24 鍙戣〃璇勮
]]>
javascript xpath 鑷畾涔夋柟娉?綰ц繛涓嬫媺妗?http://www.tkk7.com/Good-Game/archive/2007/08/14/136662.htmlG_GG_GTue, 14 Aug 2007 06:29:00 GMThttp://www.tkk7.com/Good-Game/archive/2007/08/14/136662.htmlhttp://www.tkk7.com/Good-Game/comments/136662.htmlhttp://www.tkk7.com/Good-Game/archive/2007/08/14/136662.html#Feedback0http://www.tkk7.com/Good-Game/comments/commentRss/136662.htmlhttp://www.tkk7.com/Good-Game/services/trackbacks/136662.html 闂: IE,FF鐢?xpath 鍦╦avascript鍔ㄦ佽В璇?
瑙e喅: 鑷畾涔塲sXpath 綾?br />
js.js
//鍏抽敭鏄?jsXpath 綾?br />//浣跨敤鏄?new 騫?緇欏睘鎬?domx 鍊?DOMXml
//var nodes = obj.getPathNodes( xpath ); 灝辨槸 xpath璇彞濡?
//beans/bean
//鍐?var node = obj.next( nodes )
//node 鍙互浣跨敤浜?/b>

var聽dom聽=null聽;
var聽jp聽=new聽jsXpath();

function聽load(ul){
聽聽聽聽
new聽Ajax.Request(
聽聽聽聽聽聽聽聽ul,
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽method:聽'get',
聽聽聽聽聽聽聽聽聽聽聽聽onComplete:聽action聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽});聽聽聽聽
}

function聽action(req){
var聽path聽="聽/beans/bean[string-length(@xid)<3]聽";
聽dom聽
=聽req.responseXML聽;
聽jp.domx聽
=聽dom聽;聽
var聽list聽=聽聽jp.getPathNodes(path)聽;
聽createSelect(jp,list,聽document.getElementById('ii')聽);
//寤?select ii
}

function聽jsXpath(){
聽聽聽聽
this.nexti聽=0聽;
聽聽聽聽
this.domx聽=null聽;
聽聽聽聽
聽聽聽聽
this.getPathNodes聽=function(path){
聽聽聽聽聽聽聽聽
var聽val聽=null聽;
聽聽聽聽聽聽聽聽
if(聽navigator.appName.indexOf('Microsoft')==-1聽){
聽聽聽聽聽聽聽聽聽聽聽val聽聽
=聽document.evaluate(path,this.domx聽,null,XPathResult.ANY_TYPE,null聽)聽;
聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽
this.domx.setProperty("SelectionLanguage","XPath");
聽聽聽聽聽聽聽聽聽聽聽聽val聽
=this.domx.documentElement.selectNodes(聽path聽)聽;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
return聽val聽;
聽聽聽聽}
聽聽聽聽
聽聽聽聽
this.next聽=聽聽function(domp,ii){
聽聽聽聽聽聽聽聽
if(聽navigator.appName.indexOf('Microsoft')==-1聽){
聽聽聽聽聽聽聽聽聽聽聽
return聽domp.iterateNext()聽;
聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽
if(ii!=null)聽this.nexti聽=聽ii聽;
聽聽聽聽聽聽聽聽聽聽聽聽
return聽domp[this.nexti++];
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

function聽createSelect(xpath,doms,sele){
聽聽聽聽聽聽聽聽
try{
聽聽聽聽聽聽聽聽聽聽聽聽
var聽item=xpath.next(doms);
聽聽聽聽聽聽聽聽聽聽聽聽
while(item){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
var聽opt聽=document.createElement('option');
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
var聽text=document.createTextNode(聽item.firstChild.nodeValue聽聽);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽opt.appendChild(text);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽opt.setAttribute(
"value",item.getAttribute('xid')聽);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sele.appendChild(opt);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽item聽
=聽xpath.next(doms);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
catch(e){dump(e);}
}

//寤?select jj 涓?select ii鐨?selectedIndex 鏈夊叧
function聽duSel(){
聽聽聽聽聽聽聽聽
var聽sele聽=聽document.getElementById('jj');
聽聽聽聽聽聽聽聽
var聽sdom聽=聽document.getElementById('ii');
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
var聽num聽=聽sele.getElementsByTagName('option').length-1;聽
聽聽聽聽聽聽聽聽
for(var聽i=num;聽i>0聽;聽i--)聽
聽聽聽聽聽聽聽聽聽聽聽聽sele.remove(
1);聽
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽
var聽skey聽=聽sdom.options[聽sdom.selectedIndex聽].value

聽聽聽聽聽聽聽聽聽
var聽path聽="/beans/bean[聽聽starts-with(聽@xid聽,聽'"+skey+"')聽and聽string-length(@xid)>3聽聽]";

聽聽聽聽聽聽聽聽聽
var聽jpp聽=new聽jsXpath();
聽聽聽聽聽聽聽聽聽jpp.domx聽
=聽dom聽;聽
聽聽聽聽聽聽聽聽聽
var聽lj聽=聽jpp.getPathNodes(path);

聽聽聽聽聽聽聽聽聽createSelect(jpp,lj,聽document.getElementById('jj')聽);
}

xml.xml
<?xml聽version="1.0"聽encoding="GB2312"聽standalone="no"?>
<beans>
聽聽聽聽
<bean聽xid='01'聽>鍖椾含灞</bean>
聽聽聽聽
<bean聽xid='0101'>ftd</bean>
聽聽聽聽
<bean聽xid='0102'>tsd</bean>

聽聽聽聽
<bean聽xid='02'>娌堥槼灞</bean>
聽聽聽聽
<bean聽xid='0202'>sy1</bean>
聽聽聽聽
<bean聽xid='0203'>sy2</bean>
聽聽聽聽
<bean聽xid='0204'>sy3</bean>
</beans>

xpath.html //綰ц繛鐨?涓嬫媺妗嗗嚭鏉ヤ簡
<html>
聽聽聽聽
<head>
聽聽聽聽聽聽聽聽
<meta聽http-equiv="Content-Type"聽content="text/html;聽charset=gb2312"/>
聽聽聽聽聽聽聽聽
<script聽language='JavaScript'聽src="js/js.js"></script>
聽聽聽聽聽聽聽聽
<script聽language="JavaScript"聽src="lib/prototype/prototype.js"></script>
聽聽聽聽聽聽聽聽
<script聽language='JavaScript'聽src='js/xpath.js'></script>
聽聽聽聽
</head>

聽聽聽聽
<body聽onload='load(聽"./xml/xml.xml"聽)'>聽聽聽聽
聽聽聽聽聽聽聽聽
<select聽id="ii"聽onchange='duSel();'>
聽聽聽聽聽聽聽聽聽聽聽聽聽
<option聽value="">--孌甸夋嫨--</option>
聽聽聽聽聽聽聽聽
</select>
聽聽聽聽聽聽聽聽
<select聽id="jj">
聽聽聽聽聽聽聽聽聽聽聽聽聽
<option聽value="">--杞﹂棿閫夋嫨--</option>
聽聽聽聽聽聽聽聽
</select>
聽聽聽聽
</body>
</html>

蹇冨緱: xpath 鏄ソ涓滆タ 濂戒笢瑗垮晩


G_G 2007-08-14 14:29 鍙戣〃璇勮
]]>
javascript Xpath 灝忎緥http://www.tkk7.com/Good-Game/archive/2007/08/13/136365.htmlG_GG_GMon, 13 Aug 2007 05:58:00 GMThttp://www.tkk7.com/Good-Game/archive/2007/08/13/136365.htmlhttp://www.tkk7.com/Good-Game/comments/136365.htmlhttp://www.tkk7.com/Good-Game/archive/2007/08/13/136365.html#Feedback0http://www.tkk7.com/Good-Game/comments/commentRss/136365.htmlhttp://www.tkk7.com/Good-Game/services/trackbacks/136365.html 闂錛?/b> java 鍙互鐢?xpath ; javascriopt 涔熷彲浠ワ紒
瑙e喅錛?/b> document.evaluate 鏂規硶
鍙傝冿細嫻忚鍣ㄤ腑鐨刋Path鏀寔
xpath.html
<html>
聽聽聽聽
<head>
聽聽聽聽聽聽聽聽
<meta聽http-equiv="Content-Type"聽content="text/html;聽charset=gb2312"/>
聽聽聽聽聽聽聽聽
<script聽language='JavaScript'聽src="js/js.js"></script>
聽聽聽聽聽聽聽聽
<script聽language="JavaScript"聽src="lib/prototype/prototype.js"></script>
聽聽聽聽
</head>
聽聽聽聽
<body聽onload='load(聽"./xml/xml.xml"聽)'>聽聽聽聽
聽聽聽聽
</body>
</html>
// xpath.js 鏄竴涓墿灞曞寘鍦ㄨ繖閲屾槸鍙互緇熶竴 鏂規硶IE 錛孎F閮藉彲浠ヤ嬌鐢?evaluate鏂規硶
// http://www.tkk7.com/Files/Good-Game/xpath.rar 涓嬭澆
// 璇存槑聽 http://dev.infoaccelerator.net/spryDocs/overview-summary.html



G_G 2007-08-13 13:58 鍙戣〃璇勮
]]>
java Xpath 灝忎緥http://www.tkk7.com/Good-Game/archive/2007/08/03/134261.htmlG_GG_GFri, 03 Aug 2007 07:46:00 GMThttp://www.tkk7.com/Good-Game/archive/2007/08/03/134261.htmlhttp://www.cnblogs.com/zixin/category/60411.html


import聽java.util.*;聽import聽org.jdom.*;聽
import聽org.jdom.xpath.*;聽
import聽org.jdom.input.*;聽
import聽org.jdom.output.*;聽
import聽java.io.*;聽
import聽org.jdom.xpath.*;聽
import聽org.saxpath.*;聽
publicclass聽TestXML聽{聽
聽聽
publicstaticvoid聽main(String[]聽args)聽{聽
聽聽聽聽
try聽{聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽SAXBuilder聽sb聽
=new聽SAXBuilder();聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽Document聽doc聽
=聽sb.build(new聽FileInputStream("/book.xml"));聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽String聽strPath聽
="//book/author";聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽XPath聽path聽
=聽XPath.newInstance(strPath);聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽List聽lst聽
=聽path.selectNodes(doc);聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
for聽(Iterator聽it聽=聽lst.iterator();聽it.hasNext();)聽{聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽Element聽at聽
=聽(Element)聽it.next();聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(at.getText());聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽}聽
catch聽(Exception聽e)聽{聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽e.printStackTrace();
聽聽聽}
聽聽}
}聽





G_G 2007-08-03 15:46 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 久久精品国产这里是免费| 亚洲自偷自拍另类12p| 亚洲精品无码少妇30P| 无码国产精品一区二区免费式影视| 亚洲精品无码专区久久同性男| 亚洲av一本岛在线播放| 可以免费看的卡一卡二| 亚洲综合久久精品无码色欲| 国产桃色在线成免费视频 | 亚洲级αV无码毛片久久精品| 丰满妇女做a级毛片免费观看| 久久影视国产亚洲| 一区二区三区无码视频免费福利| 亚洲高清在线观看| 13一14周岁毛片免费| 亚洲精品456人成在线| 国产在线观看免费不卡 | 1000部无遮挡拍拍拍免费视频观看| 亚洲av午夜福利精品一区人妖| 久久这里只精品99re免费| 亚洲熟妇色自偷自拍另类| 啦啦啦高清视频在线观看免费| 看亚洲a级一级毛片| 国产成人综合亚洲亚洲国产第一页 | 成年18网站免费视频网站| 美女18毛片免费视频| 国产亚洲精品a在线无码| **aaaaa毛片免费| www亚洲精品久久久乳| 亚洲人成网77777色在线播放| 日韩午夜理论免费TV影院| 亚洲熟女精品中文字幕| 久久久无码精品亚洲日韩软件| 久久成人免费电影| 亚洲Aⅴ在线无码播放毛片一线天 亚洲avav天堂av在线网毛片 | 成全视频免费高清| 久久国产美女免费观看精品| 亚洲制服丝袜一区二区三区| 免费永久看黄在线观看app| 一级特黄aa毛片免费观看| 亚洲av无码一区二区三区人妖 |