In the first few months, some XML operations were organized when they were doing projects. Here, according to your own programming habits, do it. The most basic of XML operation is SAX, DOM. But here is not talking about SAX, DOM how to use. Instead, it will talk about its Java implementation from the perspective of XML elements. XML is composed of multiple elements, which can be divided into several basic types, such as Xmlelement, XmlSimpleElement, XMLComplexElement, XmlCollection, XmlCollectionElement, and from class names you can determine the XML objects described in this class.
The following is a description with an example:
XML Version = "1.0" encoding = "GB2312"?>
borders>
style>
Styles>
Columns>
Regions>
Cells>
Sheet>
File>
Package>
This configuration file is an XML file of XML-> Excel, describing some of Excel, such as file name, font, row, column, etc. The package is an XMLComplexElement (mixed type), Cells (cell set) is an XMLCollection, Cell (cell) is XMLCollectionElement (element in the container)
Public class Cell Extends XmlcollectionElement {
Private xmlattribute attrrow = new xmlattribute ("row");
Private XMlattribute Attryle = New Xmlattribute ("style");
Private XMlattribute AttrColumn = New XMlattribute ("Column");
Private XMlattribute AttrValue = New XMlattribute ("Value");
Private xmlinterface xmlinterface = null;
Public cell (Cells ASS) {
Super (ASS);
Fillstructure ();
}
Protected void Fillstructure () {
Super.fillstructure ();
Attrid.setReadonly (TRUE);
IsRequired = true;
ComplexStructure.Add (attrstyle);
ComplexStructure.Add (attrrow);
ComplexStructure.Add (attrcolumn);
ComplexStructure.Add (AttrValue);
}
}
Source code Http://www.51sports.org/xml.rar