以文本方式查看主题 - 中文XML论坛 - 专业的XML技术讨论区 (http://bbs.xml.org.cn/index.asp) -- 『 XML基础 』 (http://bbs.xml.org.cn/list.asp?boardid=1) ---- 如何用jsp+xml进行数据的储存和读出操作 (http://bbs.xml.org.cn/dispbbs.asp?boardid=1&rootid=&id=54579) |
-- 作者:goodtolove001 -- 发布时间:10/29/2007 2:16:00 PM -- 如何用jsp+xml进行数据的储存和读出操作 只知道xml可以用来存数据,但是不知到底如何作。 我想把数据一组一组的存进去(就像数据库表中的一条记录一样),读出的时候可以根据条件选择读哪一条或是哪个字段!! 不知哪位可以相告,不胜感激!!急用啊!! |
-- 作者:jiangyou001 -- 发布时间:11/15/2007 3:42:00 PM -- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); File xmlfile = new File( "D:\\resin-3.0.8\\deploy\\FF\\WEB-INF\\student.xml"); Document doc = null; doc = builder.parse(xmlfile); } public static Document addStudent(Document doc, String sid, String sname, int sjava, int soracle) { Element student = doc.createElement("student"); Element name = doc.createElement("name"); Element source = doc.createElement("source"); Element java = doc.createElement("java"); Element oracle = doc.createElement("oracle"); student.setAttribute("sid", sid); name.appendChild(doc.createTextNode(sname)); java.appendChild(doc.createTextNode(String.valueOf(sjava))); oracle.appendChild(doc.createTextNode(String.valueOf(soracle))); source.appendChild(java); source.appendChild(oracle); student.appendChild(name); student.appendChild(source); doc.getDocumentElement().appendChild(student); return doc; } |
W 3 C h i n a ( since 2003 ) 旗 下 站 点 苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》 |
3,441.406ms |