锘??xml version="1.0" encoding="utf-8" standalone="yes"?>日韩av一区二区三区四区 ,99精品黄色片免费大全,欧美激情亚洲综合一区http://www.aygfsteel.com/lnj-lin/zh-cnThu, 19 Jun 2025 00:23:24 GMTThu, 19 Jun 2025 00:23:24 GMT60JDom浣跨敤璇﹁В(杞?http://www.aygfsteel.com/lnj-lin/archive/2006/09/17/70154.html澶辨帶鐨勯槼鍏?/dc:creator>澶辨帶鐨勯槼鍏?/author>Sun, 17 Sep 2006 12:12:00 GMThttp://www.aygfsteel.com/lnj-lin/archive/2006/09/17/70154.htmlhttp://www.aygfsteel.com/lnj-lin/comments/70154.htmlhttp://www.aygfsteel.com/lnj-lin/archive/2006/09/17/70154.html#Feedback0http://www.aygfsteel.com/lnj-lin/comments/commentRss/70154.htmlhttp://www.aygfsteel.com/lnj-lin/services/trackbacks/70154.html聽(tīng)JDom鏄笉閿欑殑API錛岀畻寰椾笂綆鍗曢珮鏁堬紝鏈閲嶈鏄凡緇忔垚涓簀cp鐨勪竴閮ㄥ垎錛岃繖涓挶寰?br />寮勫紕銆備笉www.jdom.org涓婂啓鏂囨。鐨勪漢瀹炲湪澶噿錛屾枃妗e嚭濂囩殑灝戯紝嫻佷紶寰楁渶騫跨殑鎭愭曟槸IBM涓婇潰鐨勪竴綃囥奐Dom璁﹋ava聽(tīng)XML鍙樺緱瀹規(guī)槗銆嬶紝涓?br />榪囪繖綃囨枃绔犲彧娑夊強(qiáng)鍩烘湰鐨勮鍐欐搷浣滐紝榪滀笉鑳借儨浠誨疄闄呭伐浣溿傝姳浜?jiǎn)涓ゅぉ鏃堕椷_(dá)紝鎶奐Dom鐨勫熀鏈搷浣滄暣鐞嗗嚭鏉ヤ簡(jiǎn)錛屾兜鐩栦簡(jiǎn)澶ч儴鍒嗙殑鎿嶄綔錛氬厓绱犮佸睘鎬с佸懡鍚嶇┖闂淬?br />PI銆丏TD銆丼chema錛屽簲浠樹(shù)竴鑸殑搴旂敤娌′粈涔堥棶棰樸傚弽姝f垜娌℃湁鍦ㄧ綉涓婅鍒版洿鍔犺灝界殑鐗堟湰錛屼綘瑙佽繃鐨勮瘽錛岃鐣欎笅榪炴帴銆傛殏鏃舵潵涓嶅強(qiáng)緙栧啓璇︾粏鐨勮鏄庯紝鍏堝笘
鍑犳紼嬪簭錛屽鏈夌粡楠岀殑Java寮鍙戣呮潵璇達(dá)紝宸茬粡瓚沖浜?jiǎn)銆傜▼搴忛兘宸茬粡緇忚繃浜?jiǎn)瀹為檯鐨剫箣璇曞Q屾垜浣跨敤鐨凧Dom鏄?.9鐗堛?/p>

聽(tīng)1銆佸垱寤篨ML鏂囨。錛?br />聽(tīng)import聽(tīng)java.io.*;
聽(tīng)import聽(tīng)org.jdom.*;
聽(tīng)import聽(tīng)org.jdom.input.*;
聽(tīng)import聽(tīng)org.jdom.output.*;

聽(tīng)public聽(tīng)class聽(tīng)CreateXML
聽(tīng){
聽(tīng)聽(tīng)public聽(tīng)void聽(tīng)Create()
聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)try
聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)Document聽(tīng)doc聽(tīng)=聽(tīng)new聽(tīng)Document();聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)ProcessingInstruction聽(tīng)pi=new聽(tīng)ProcessingInstruction("xml-stylesheet","type="text/xsl"聽(tīng)href="test.xsl"");
聽(tīng)聽(tīng)聽(tīng)聽(tīng)doc.addContent(pi);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)Namespace聽(tīng)ns聽(tīng)=聽(tīng)Namespace.getNamespace("http://www.bromon.org" );
聽(tīng)聽(tīng)聽(tīng)聽(tīng)Namespace聽(tīng)ns2聽(tīng)=聽(tīng)Namespace.getNamespace("other",聽(tīng)"http://www.w3c.org" );

聽(tīng)聽(tīng)聽(tīng)聽(tīng)Element聽(tīng)root聽(tīng)=聽(tīng)new聽(tīng)Element("鏍瑰厓绱?,聽(tīng)ns);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)root.addNamespaceDeclaration(ns2);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)doc.setRootElement(root);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)Element聽(tīng)el1聽(tīng)=聽(tīng)new聽(tīng)Element("鍏冪礌涓");
聽(tīng)聽(tīng)聽(tīng)聽(tīng)el1.setAttribute("灞炴?,聽(tīng)"灞炴т竴");
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)Text聽(tīng)text1=new聽(tīng)Text("鍏冪礌鍊?);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)Element聽(tīng)em聽(tīng)=聽(tīng)new聽(tīng)Element("鍏冪礌浜?).addContent("絎簩涓厓绱?);

聽(tīng)聽(tīng)聽(tīng)聽(tīng)el1.addContent(text1);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)el1.addContent(em);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)Element聽(tīng)el2聽(tīng)=聽(tīng)new聽(tīng)Element("鍏冪礌涓?).addContent("絎笁涓厓绱?);

聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)root.addContent(el1);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)root.addContent(el2);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)//緙╄繘鍥涗釜絀烘牸,鑷姩鎹㈣,gb2312緙栫爜
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)XMLOutputter聽(tīng)outputter聽(tīng)=聽(tīng)new聽(tīng)XMLOutputter("聽(tīng)聽(tīng)",聽(tīng)true,"GB2312");
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)outputter.output(doc,聽(tīng)new聽(tīng)FileWriter("test.xml"));
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}catch(Exception聽(tīng)e)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)System.out.println(e);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)public聽(tīng)static聽(tīng)void聽(tīng)main(String聽(tīng)args[])
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)new聽(tīng)CreateXML().Create();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)}

聽(tīng)2銆丏TD楠岃瘉鐨勶細(xì)
聽(tīng)import聽(tīng)java.io.*;
聽(tīng)import聽(tīng)org.jdom.*;
聽(tīng)import聽(tīng)org.jdom.input.*;
聽(tīng)import聽(tīng)org.jdom.output.*;

聽(tīng)public聽(tīng)class聽(tīng)XMLWithDTD
聽(tīng){
聽(tīng)聽(tīng)public聽(tīng)void聽(tīng)validate()
聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)try
聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)SAXBuilder聽(tīng)builder聽(tīng)=聽(tīng)new聽(tīng)SAXBuilder(true);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)builder.setFeature("http://xml.org/sax/features/validation";,true);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)Document聽(tīng)doc聽(tīng)=聽(tīng)builder.build(new聽(tīng)FileReader("author.xml"));
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)System.out.println("鎼炴巶");
聽(tīng)聽(tīng)聽(tīng)聽(tīng)XMLOutputter聽(tīng)outputter聽(tīng)=聽(tīng)new聽(tīng)XMLOutputter();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)outputter.output(doc,聽(tīng)System.out);
聽(tīng)聽(tīng)聽(tīng)}catch(Exception聽(tīng)e)
聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)System.out.println(e);
聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)public聽(tīng)static聽(tīng)void聽(tīng)main(String聽(tīng)args[])
聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)new聽(tīng)XMLWithDTD().validate();
聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)
聽(tīng)}

聽(tīng)
闇瑕佽鏄庣殑鏄紝榪欎釜紼嬪簭娌℃湁鎸囨槑浣跨敤鍝釜DTD鏂囦歡銆侱TD鏂囦歡鐨勪綅緗槸鍦╔ML涓寚瀹氱殑錛岃屼笖DTD涓嶆敮鎸佸懡鍚嶇┖闂達(dá)紝涓涓猉ML鍙兘寮曠敤涓涓狣TD錛屾墍
浠ョ▼搴忕洿鎺ヨ鍙朮ML涓寚瀹氱殑DTD錛岀▼搴忔湰韜笉鐢ㄦ寚瀹氥備笉榪囪繖鏍蜂竴鏉ワ紝濂借薄灝卞彧鑳戒嬌鐢ㄥ閮ㄥ紡鐨凞TD寮曠敤鏂瑰紡浜?jiǎn)锛熼珮?shù)漢鎸囩偣銆?/p>

聽(tīng)3銆乆ML聽(tīng)Schema楠岃瘉鐨勶細(xì)
聽(tīng)import聽(tīng)java.io.*;
聽(tīng)import聽(tīng)org.jdom.*;
聽(tīng)import聽(tīng)org.jdom.input.*;
聽(tīng)import聽(tīng)org.jdom.output.*;

聽(tīng)public聽(tīng)class聽(tīng)XMLWithSchema
聽(tīng){
聽(tīng)聽(tīng)String聽(tīng)xml="test.xml";
聽(tīng)聽(tīng)String聽(tīng)schema="test-schema.xml";
聽(tīng)聽(tīng)public聽(tīng)void聽(tīng)validate()
聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)try
聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)SAXBuilder聽(tīng)builder聽(tīng)=聽(tīng)new聽(tīng)SAXBuilder(true);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)//鎸囧畾綰︽潫鏂瑰紡涓篨ML聽(tīng)schema
聽(tīng)聽(tīng)聽(tīng)聽(tīng)builder.setFeature("http://apache.org/xml/features/validation/schema";, 聽(tīng)true);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)//瀵煎叆schema鏂囦歡
聽(tīng)聽(tīng)聽(tīng)聽(tīng)builder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";,schema);
聽(tīng)聽(tīng)聽(tīng)聽(tīng)Document聽(tīng)doc聽(tīng)=聽(tīng)builder.build(new聽(tīng)FileReader(xml));
聽(tīng)聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)聽(tīng)聽(tīng)System.out.println("鎼炴巶");
聽(tīng)聽(tīng)聽(tīng)聽(tīng)XMLOutputter聽(tīng)outputter聽(tīng)=聽(tīng)new聽(tīng)XMLOutputter();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)outputter.output(doc,聽(tīng)System.out);
聽(tīng)聽(tīng)聽(tīng)}catch(Exception聽(tīng)e)
聽(tīng)聽(tīng)聽(tīng){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)System.out.println("楠岃瘉澶辮觸:"+e);
聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)聽(tīng)
聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)
聽(tīng)}

聽(tīng)涓婇潰鐨勭▼搴忓氨鎸囧嚭浜?jiǎn)瑕佸紩鍏ョ殑XML聽(tīng)Schema鏂囦歡鐨勪綅緗?/p>

聽(tīng)緋葷粺榛樿杈撳嚭鏄疷TF-8錛岃繖鏈夊彲鑳藉鑷村嚭鐜頒貢鐮併?/p>

聽(tīng)璇籜ML鏂囨。鐨勬妧宸у湪緗戜笂宸茬粡娉涙互錛岃繖閲屽氨娌℃湁鍐嶅垪鍑烘潵銆?/p>

]]>
主站蜘蛛池模板: 铜梁县| 黑山县| 乳山市| 奇台县| 东山县| 吉首市| 务川| 清流县| 普宁市| 阿合奇县| 闽侯县| 罗定市| 祁东县| 惠水县| 洛川县| 甘孜| 高雄县| 固阳县| 三门县| 阿拉善左旗| 五指山市| 思茅市| 新泰市| 晋州市| 改则县| 乐昌市| 奉化市| 三台县| 奉新县| 班玛县| 淮滨县| 鄂托克前旗| 华阴市| 苏尼特右旗| 潮安县| 林周县| 芷江| 铜山县| 乌拉特后旗| 松滋市| 六盘水市|