jdom对xml文件的读写操作
jdom对xml文件的读写操作
1. 读取XML文件Java源代码:
1) xml文件:
<?xml version="1.0" encoding="gb2312"?>
<messages>
<message id="1">
<title>软件工程师</title>
<content>
<name>solidwang</name>
<age>23</age>
</content>
<email>wzzcctv@126.com</email>
</message>
<message id="2">
<title>导游</title>
<content>
<name>eillenwang</name>
<age>20</age>
</content>
<email>eillenwang@163.com</email>
</message>
</messages>
2) 读取xml文件的Java源代码:
package com.solid.xml;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
public class ReadXML {
public static void main(String[] args) throws FileNotFoundException, JDOMException {
//创建构造器
SAXBuilder sb = new SAXBuilder();
//读入指定文件
Document doc = sb.build(new FileInputStream("WebRoot/xmlFile/test.xml"));
//获得根节点
&
相关文档:
声明
/// <summary>
/// XML文档
/// </summary>
XmlDocument xmldoc;
&n ......
xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<mobile-list>
<mobile type="Nokia2652">
<wap2>false</wap2>
<width>115</width>
</mobile>
<mobile type="Nokia2650">
......
<%
'
Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET","http://127.0.0.1/1.xml",False
http.send
Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
'xml.load (Server.MapPath("1.xml")) '如果不是远程文件直接这一步
xml.Load(http.ResponseXML)
Dim t ......
<?
/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
* Arguments : $contents - The XML text
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the ......
ArrayCollection转成xml类型示例
下面模拟一组数据exams,将其转化为xml形式.详细代码见下:
Xml代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12" creationComplet ......