[code=text][/code]<?xml version="1.0" encoding="UTF-8"?>
<data>
<tab name="ordinarytablespaceinfo">
<head columns="表空间名,表空间大小(M),已使用空间(M),使用比,空闲空间(M),最大块(M)"/>
<row>
<column value="SYSAUX"/>
<column value="620"/>
<column value="579.5"/>
<column value=" 93.47"/>
<column value="40.5"/>
<column value="36"/>
</row>
<row>
<column value="UNDOTBS1"/>
<column value="45"/>
<column value="25.06"/>
<column value=" 55.69"/>
<column value="19.94"/>
<column value="17.19"/>
</row>
</tab>
<tab name="sort_top100sql"<head columns="PARSING_USER_ID,EXECUTIONS,SORTS,COMMAND_TYPE,DISK_READS,SQL_TEXT,HASH_VALUE"/>
<row>
<column value="85"/>
<column value="76,150"/>
<column value="76,150"/>
<column value="3"/>
<column value="0"/>
<column value="SELECT TRIGGER_NAME, TRIGGER_GROUP, NEXT_FIRE_TIME FROM QRTZ_TRIGGERS WHERE TRIGGER_STATE = :1 AND NEXT_FIRE_TIME < :2 AND (NEXT_FIRE_TIME >= :3) ORDER BY NEXT_FIRE_TIME ASC, PRIORITY DESC"/>
<column value="877,148,557"/>
</row>
<row>
<column value="85"/>
<column value="19"/>
<column value="26,918"/>
<column value="3"/>
<column value="1,178"/>
<column value="select s.synonym_name object_name, o.object_type from all_synonyms s, sys.all_objects o where s.owner in ('PUBLIC', :schema) and o.owner = s.table_owner and o.object_name = s.table_name and o.object_type in ('TABLE', 'VIEW', 'PACKAGE','TYPE', 'PROCEDURE', 'FUNCTION', 'SEQUENCE') "/>
<column value="3,767,872,888"/>
</row>
<row>
<column value="85"/>
<column value="161"/>
<column value="161"/>
<column value="3"/>
<column value="0"/>
<column value="SELECT CONF_TYPE FROM MOCHA_SYS_CONFIGURATION GROUP BY CONF_TYPE ORDER BY CONF_TYPE "/>
<column value="339,373,266"/>
</row>
<row>
<column value="85"/>
<column value="54"/>
<column value="104"/>
<column value="3"/>
<column value="4"/>
<column value="select t.*, o.*, m.comments from sys.all_tables t, sys.all_tab_comments m, sys.all_objects o where t.owner = :object_owner and t.table_name = :object_name and m.owner (+) = :object_owner and m.table_name (+) = :object_name and o.owner (+) = :object_owner and o.object_name (+) = :object_name and :object_type is not null and :sub_object is null "/>
<column value="3,148,698,940"/>
</row>
<row>
<column value="85"/>
<column value="60"/>
<column value="60"/>
<column value="3"/>
<column value="1"/>
<column value="SELECT * FROM MOCHA_BO_OPERATION WHERE OPERATION_NAME = :1 ORDER BY STATE "/>
<column value="2,946,917,090"/>
</row>
</tab>
</data>
------解决思路----------------------
jaxb !!
------解决思路----------------------
我也很久没玩过了。写的不好
@XmlRootElement(name="data")
@XmlAccessorType(XmlAccessType.FIELD)
public class XMLObject {
@XmlElement(name="tab")
private Set<XMLTable> tabs = new HashSet<XMLTable>();
public Set<XMLTable> getTabs() {
return tabs;
}
public void setTabs(Set<XMLTable> tabs) {
this.tabs = tabs;
}
}
@XmlAccessorType(XmlAccessType.FIELD)
public class XMLTable {
@XmlAttribute
private String name;
@XmlElement
private XMLHead head = new XMLHead();
@XmlElement(name ="row")
private Set<XMLRow> rows = new HashSet<XMLRow>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<XMLRow> getRows() {
return rows;
}
public void setRows(Set<XMLRow> rows) {
this.rows = rows;
}
public XMLHead getHead() {
return head;
}
public void setHead(XMLHead head) {
this.head = head;
}
}
@XmlAccessorType(XmlAccessType.FIELD)
public class XMLHead {
@XmlAttribute
private String columns;
public XMLHead() {
super();
}
public XMLHead(String columns) {
super();
this.columns = columns;
}
}
@XmlAccessorType(XmlAccessType.FIELD)
public class XMLRow {
private Set<XMLColumn> column = new HashSet<XMLColumn>();
public Set<XMLColumn> getColumn() {
return column;
}
public void setColumn(Set<XMLColumn> column) {
this.column = column;
}
}
@XmlAccessorType(XmlAccessType.FIELD)
public class XMLColumn {
@XmlAttribute
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
public class XMLTest {
public static void main(String[] args) throws Exception {
File file = new File("XXXXXX.XML");
JAXBContext jaxbContext = JAXBContext.newInstance(XMLObject.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
Object obj = jaxbUnmarshaller.unmarshal(file);
System.out.println(JSONObject.toJSONString(obj));
XMLObject o = (XMLObject) jaxbUnmarshaller.unmarshal(file);
System.out.println(JSONObject.toJSONString(o));
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(o, System.out);
}
}