lucene ½âÎöxml
ÉîδÀ´¼¼Êõ
1¡¢°²×°DOM4j
http://www.dom4j.org/
2¡¢°²×°jaxen
http://jaxen.org/releases.html
3¡¢´úÂë
package extract;
import java.io.*;
import org.dom4j.*;
import org.dom4j.io.*;
import java.util.*;
public class XmlExtract {
private SAXReader reader;
private Document document;
/**
* @param args
*/
public XmlExtract(){
reader=new SAXReader();
try {
document=reader.read(new File("./htmls/abcde.xml"));
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@SuppressWarnings("unchecked")
public void exxml(String path){
if (document==null) return;
List l=document.selectNodes(path);
System.out.println(path);
Iterator it=l.iterator();
while (it.hasNext()){
Element ele=(Element) it.next();
List li=ele.elements();
Iterator i=li.iterator();
while (i.hasNext()){
Element e=(Element) i.next();
System.out.println("name:"+e.getName()+"\t text:"+e.getText());
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
XmlExtract xmlext=new XmlExtract();
xmlext.exxml("/Config/vmacore/threadPool");
}
}
4¡¢Ð§¹ûÓë½Øͼ
/Config/vmacore/threadPool
name:TaskMax te
Ïà¹ØÎĵµ£º
//¶ÁÈ¡XMLÎļþ
//1¡¢LoadfromFile×°ÈëXMLÎļþ
//2¡¢Ö¸¶¨Â·¾¶£¬¼¤»î¶ÁÈ¡
//3¡¢´ÓÄÚ´æÁ÷¶ÁÈ¡
//4¡¢´ÓÍøÂçÉÏÖ±½Ó»ñÈ¡
//1¡¢LoadfromFile×°ÈëXMLÎļþ
procedure TForm1.Button1Click(Sender: TObject);
begin
XMLDocument1.LoadfromFile('c:\temp\test.xml');
// XMLDocument1.Active := True;
Memo1.Lines := X ......
1£©DOM£¨JAXP Crimson½âÎöÆ÷£©
DOMÊÇÓÃÓëƽ̨ºÍÓïÑÔÎ޹صķ½Ê½±íʾXMLÎĵµµÄ¹Ù·½W3C±ê×¼¡£DOMÊÇÒÔ²ã´Î½á¹¹×éÖ¯µÄ½Úµã»òÐÅϢƬ¶ÏµÄ¼¯ºÏ¡£Õâ¸ö²ã´Î½á¹¹ÔÊÐí¿ª·¢ÈËÔ±ÔÚÊ÷ÖÐÑ°ÕÒÌض¨ÐÅÏ¢¡£·ÖÎö¸Ã½á¹¹Í¨³£ÐèÒª¼ÓÔØÕû¸öÎĵµºÍ¹¹Ôì²ã´Î½á¹¹£¬È»ºó²ÅÄÜ×öÈκι¤×÷¡£ÓÉÓÚËüÊÇ»ùÓÚÐÅÏ¢²ã´ÎµÄ£¬Òò¶ ......
/// <summary>
/// ¶ÁÈ¡Êý¾Ý¼¯²¢¼ÓÈ뻺´æ
/// sea 2009-12-11
/// </summary>
&nb ......
XML Schema union ÔªËØ
¶¨ÒåºÍÓ÷¨
union ÔªËض¨Òå¶à¸ö simpleType ¶¨ÒåµÄ¼¯ºÏ¡£
ÔªËØÐÅÏ¢
³öÏÖ´ÎÊý
Ò»´Î
¸¸ÔªËØ
simpleType
ÄÚÈÝ
annotation¡¢simpleType
Óï·¨
<union
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType ......
public class yzzSerialize
{
private yzzSerialize()
{ }
private static yzzCache cache = new yzzCache();
public static T GetfromXml<T>(string xmlpath, T t)
{
using (FileStream fs = new FileStream(xmlpath, FileMode.Open, FileAcces ......