[問題] 讀取xml字串
最近在研究讀取xml的問題
是使用dom去呼叫
但找到的範例大多都是直接讀取檔案
ex:
File f=new File("data_10k.xml");
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builder=factory.newDocumentBuilder();
Document doc = builder.parse(f);
NodeList nl = doc.getElementsByTagName("VALUE");
.
.
.
想請問如果不是讀取檔案的模式
而是直接讀取一個字串
要如何修正呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.163.194.240
→
10/24 17:31, , 1F
10/24 17:31, 1F
→
10/24 17:38, , 2F
10/24 17:38, 2F
推
10/24 17:40, , 3F
10/24 17:40, 3F
經過修改後,加入這樣
InputStream xml = new ByteArrayInputStream(fff.getHello().getBytes("UTF-8"));
Document doc = builder.parse(xml);
但還是讀不出來~"~
推
10/24 17:47, , 4F
10/24 17:47, 4F
※ 編輯: jackyeah1213 來自: 118.163.194.240 (10/24 17:57)
→
10/24 18:06, , 5F
10/24 18:06, 5F
推
10/24 18:38, , 6F
10/24 18:38, 6F
→
10/25 23:17, , 7F
10/25 23:17, 7F
討論串 (同標題文章)