精彩的人生
好好工作,好好生活
BlogJava
首頁
新隨筆
聯系
聚合
管理
147 Posts :: 0 Stories :: 250 Comments :: 0 Trackbacks
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(43)
給我留言
查看公開留言
查看私人留言
隨筆分類
BIRT(1)
Eclipse(13)
EMF&GEF(6)
Google Code Jam(3)
Gossip(28)
Java(45)
Job(6)
Social Network(5)
Web(1)
Web Service(41)
我愛吃(2)
隨筆檔案
2008年9月 (1)
2008年8月 (1)
2008年3月 (1)
2008年2月 (1)
2008年1月 (1)
2007年12月 (1)
2007年11月 (2)
2007年10月 (1)
2007年7月 (1)
2007年3月 (1)
2006年10月 (9)
2006年9月 (18)
2006年8月 (4)
2006年7月 (6)
2006年6月 (3)
2006年5月 (11)
2006年4月 (27)
2006年3月 (25)
2006年2月 (6)
2006年1月 (1)
2005年12月 (20)
2005年11月 (6)
相冊
my
收藏夾
GEF/EMF/Eclipse(1)
semantic web(4)
uddi(2)
配色方案(5)
Friends
Reload_cn
uiiang
八進制
老冒的SNS專欄
Web Site
Eclipse Org
Eclipse World
網談
關注虹的新作,關注SNS
搜索
積分與排名
積分 - 445786
排名 - 123
最新評論
1.?re: 當cmd里輸入路徑包含空格的時候
謝謝分享
--網盤搜索-kaopu.so
2.?re: 當cmd里輸入路徑包含空格的時候[未登錄]
我的路徑是中文帶空格怎么辦?
%cd%/bin/bin/java -jar ../../export.jar執行不了啊
--liu
3.?re: Rare Order[未登錄]
@Guest
Wrong at all!!!!
--123
4.?re: 當cmd里輸入路徑包含空格的時候[未登錄]
很有用喲
--temp
5.?re: 插件制作過程記錄(使用TreeViewer貢獻視圖)
代碼下載不了了,
--jiaojiaf
閱讀排行榜
1.?正宗泡椒鳳爪做法(zz)(146700)
2.?當cmd里輸入路徑包含空格的時候(30580)
3.?將String轉換成InputStream(28087)
4.?轉:Eclipse插件FatJar安裝與使用(19268)
5.?簡單的將String類型的xml轉換為對象的代碼(13982)
6.?如何寫好PPT(8847)
7.?讀Axis2用戶幫助文檔(7852)
8.?2005.6.12 使用jsp上傳文件(7570)
9.?從插件/RCP中取得文件路徑的方法(6254)
10.?Eclipse的BPEL(5565)
評論排行榜
1.?正宗泡椒鳳爪做法(zz)(97)
2.?2005.6.12 圖片處理(17)
3.?如何寫好PPT(10)
4.?讀Axis2用戶幫助文檔(9)
5.?gef布局的一點感想(8)
6.?從擴展點中load class(8)
7.?從插件/RCP中取得文件路徑的方法(7)
8.?emf&gef之一example.my.gefpractice(7)
9.?轉:Eclipse插件FatJar安裝與使用(6)
10.?將String轉換成InputStream(6)
簡單的將String類型的xml轉換為對象的代碼
利用w3c的dom:
DocumentBuilderFactory?factory
=
DocumentBuilderFactory.newInstance();?
??DocumentBuilder?builder;
??
try
?
{
???builder?
=
?factory.newDocumentBuilder();
???Document?doc?
=
?builder.parse(
new
?ByteArrayInputStream(str.getBytes()));?
??}
?
catch
?(ParserConfigurationException?e)?
{
???
//
?TODO?Auto-generated?catch?block
???e.printStackTrace();
??}
?
catch
?(SAXException?e)?
{
???
//
?TODO?Auto-generated?catch?block
???e.printStackTrace();
??}
?
catch
?(IOException?e)?
{
???
//
?TODO?Auto-generated?catch?block
???e.printStackTrace();
??}
?
利用dom4j
SAXReader?saxReader?
=
?
new
?SAXReader();
????????Document?document;
????????
try
?
{
????????????document?
=
?saxReader.read(
new
?ByteArrayInputStream(str.getBytes()));
????????????Element?incomingForm?
=
?document.getRootElement();
????????}
?
catch
?(DocumentException?e)?
{
????????????
//
?TODO?Auto-generated?catch?block
????????????e.printStackTrace();
????????}
posted on 2006-07-06 11:17
hopeshared
閱讀(13982)
評論(6)
編輯
收藏
所屬分類:
Java
Feedback
#
re: 簡單的將String類型的xml轉換為對象的代碼
2006-07-06 11:41
Compass
經專家鑒定,此帖轉新手區
回復
更多評論
#
re: 簡單的將String類型的xml轉換為對象的代碼
2006-07-06 13:01
lizongbo
暈,
難道不知道有個StringReader???
Document doc = builder.parse( new java.io.StringReader(str));
回復
更多評論
#
re: 簡單的將String類型的xml轉換為對象的代碼
2006-07-06 14:24
Cisco@JAVA
dom4j :
If you have some XML as a String you can parse it back into a Document again using the helper method DocumentHelper.parseText()
String text = "<person> <name>James</name> </person>";
Document document = DocumentHelper.parseText(text);
回復
更多評論
#
re: 簡單的將String類型的xml轉換為對象的代碼
2006-07-06 14:39
hopeshared
Document doc = builder.parse( new java.io.StringReader(str)); 可以,這個parse方法傳入的參數種類還是很多的。
Cisco@JAVA 的方法也可以。
我正好寫代碼寫到這里,需要解析xml,于是就把用到的兩類都貼上來了:)
回復
更多評論
#
re: 簡單的將String類型的xml轉換為對象的代碼
2009-04-11 11:12
GOOD
@Cisco@JAVA
GOOD!
回復
更多評論
#
re: 簡單的將String類型的xml轉換為對象的代碼
2010-06-11 20:21
gaaa
騙子: Document doc = builder.parse( new java.io.StringReader(str));
這個方法 編譯都不通過
回復
更多評論
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
一段關于callback的代碼
當cmd里輸入路徑包含空格的時候
java類加載的表現形式(zz)
初探Java類加載機制的奧秘(zz)
Java類加載內幕(zz)
使用Jakarta Commons Pool處理對象池化(zz)
對象池(對象緩沖池)-高手進階(zz)
簡單的將String類型的xml轉換為對象的代碼
一段很好用的判斷數據庫中某張表是否存在的代碼
轉:Java Annotation 高級應用
Powered by:
BlogJava
Copyright © hopeshared
主站蜘蛛池模板:
崇文区
|
合江县
|
扶余县
|
荔波县
|
边坝县
|
万源市
|
绥化市
|
宁南县
|
祁连县
|
岳普湖县
|
江西省
|
桃源县
|
揭阳市
|
深圳市
|
四川省
|
岗巴县
|
昆明市
|
巴中市
|
沾化县
|
许昌县
|
长葛市
|
宁安市
|
基隆市
|
隆回县
|
宜兴市
|
屏东县
|
赫章县
|
卢龙县
|
文昌市
|
社会
|
诸暨市
|
巨鹿县
|
南陵县
|
五华县
|
改则县
|
伊宁市
|
银川市
|
昌江
|
巴里
|
双江
|
扎鲁特旗
|