zgli
BlogJava
首頁
新文章
新隨筆
聚合
管理
posts - 35, comments - 7, trackbacks - 0
jdom的簡單使用
?
import
?java.io.FileOutputStream;
import
?java.util.List;
import
?org.jdom.Attribute;
import
?org.jdom.Document;
import
?org.jdom.Element;
import
?org.jdom.input.SAXBuilder;
import
?org.jdom.output.Format;
import
?org.jdom.output.XMLOutputter;
public
?
class
?XML?
{
????
public
?
static
?
void
?main(String[]?args)?
throws
?Exception?
{
????????SAXBuilder?builder?
=
?
new
?SAXBuilder();
????????Document?doc?
=
?builder.build(
"
d:\\destination.xml
"
);
????????Element?root?
=
?doc.getRootElement();
????????root.removeChild(
"
Target
"
);
????????Element?items?
=
?root.getChild(
"
Items
"
);
????????List?item?
=
?items.getChildren(
"
item
"
);
????????
for
?(
int
?i?
=
?
0
;?i?
<
?item.size();?i
++
)?
{
????????????Element?elem?
=
?(Element)?item.get(i);
????????????Attribute?attr?
=
?elem.getAttribute(
"
displayName
"
);????????????
????????????attr.setValue(attr.getValue()?
+
?
"
中國
"
);????????????
????????}
????????
//
?保存
????????Format?format?
=
?Format.getCompactFormat();
????????format.setEncoding(
"
gb2312
"
);
????????format.setIndent(
"
??
"
);
????????XMLOutputter?XMLOut?
=
?
new
?XMLOutputter(format);
????????XMLOut.output(doc,?
new
?FileOutputStream(
"
d:\\destination_tmp.xml
"
));
????}
}
posted on 2006-05-13 09:22
java小記
閱讀(225)
評論(0)
編輯
收藏
所屬分類:
原創(chuàng)
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
<
2006年5月
>
日
一
二
三
四
五
六
30
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
1
2
3
4
5
6
7
8
9
10
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(1)
給我留言
查看公開留言
查看私人留言
隨筆分類
原創(chuàng)(1)
轉(zhuǎn)載(8)
隨筆檔案
2006年5月 (6)
2006年4月 (4)
2006年3月 (2)
2006年2月 (8)
2006年1月 (5)
2005年12月 (5)
2005年11月 (5)
搜索
最新評論
1.?re: spring的DataSource事務(wù)郁悶了我兩天[未登錄]
你救了我呀,我倒沒有郁悶2天,只有一天
--eric
2.?re: XP的Administrator用戶和自動登陸問題
好,謝謝。
--lin
3.?re: About VoIP ?
評論內(nèi)容較長,點擊標題查看
--國際長途電話站
4.?re: 關(guān)于spring的事務(wù)管理(單數(shù)據(jù)庫):純屬猜測。
cx
--桂豐大廈
5.?re: spring的DataSource事務(wù)郁悶了我兩天
我很同情你~我也是啊~
--我是大俠~
閱讀排行榜
1.?XP的Administrator用戶和自動登陸問題(5288)
2.?Tomcat加大內(nèi)存設(shè)置從windows服務(wù)啟動不生效的問題(3292)
3.?如何防止swing窗口改變大小和最小化(2712)
4.?關(guān)于java虛擬機使用內(nèi)存的思考(1891)
5.?spring的DataSource事務(wù)郁悶了我兩天(1564)
評論排行榜
1.?XP的Administrator用戶和自動登陸問題(3)
2.?spring的DataSource事務(wù)郁悶了我兩天(2)
3.?About VoIP ?(1)
4.?關(guān)于spring的事務(wù)管理(單數(shù)據(jù)庫):純屬猜測。(1)
5.?PasswordManager--從AES看到的有用代碼片段(0)
Copyright ©2025 java小記 Powered By
博客園
模板提供:
滬江博客
主站蜘蛛池模板:
武安市
|
金平
|
红桥区
|
象州县
|
邹平县
|
青田县
|
广平县
|
鄱阳县
|
北宁市
|
漯河市
|
贡山
|
调兵山市
|
自贡市
|
石柱
|
宁海县
|
隆德县
|
喀喇
|
西青区
|
阿鲁科尔沁旗
|
泊头市
|
巴林左旗
|
泸溪县
|
浮梁县
|
鸡东县
|
晋州市
|
青河县
|
盐源县
|
罗源县
|
大同县
|
萨迦县
|
栖霞市
|
武川县
|
申扎县
|
上杭县
|
易门县
|
北辰区
|
永嘉县
|
乐业县
|
中宁县
|
秦皇岛市
|
常宁市
|