Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Ò»¸öÓÃDom4j½âÎöxmlµÄÀý×Ó

Ò»¡¢²âÊÔÓõÄem.xml
<?xml version="1.0" encoding="GB2312"?>
 <EW cmd="login" mod="Login" version="6.0">
   <Source uns="" type="user"/>
   <Username>zhangzhiyun@hp</Username>
   <Password>111111</Password>
  <Version>6.01.06.00</Version>
</EW>
¶þ¡¢Dom4jTest.java
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.dom4j.Attribute;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
/**
* @author julysea
*
* Ò»¸öÓÃDom4j½âÎöxmlµÄÀý×Ó
*
*/
public class Dom4jTest {
private static final Logger logger = Logger.getLogger(Dom4jTest.class);
public static void main(String[] args) throws IOException,
DocumentException {
BufferedReader reader=new BufferedReader(new FileReader("ew.xml"));
String tempStr;
String ewXml="";
while((tempStr=reader.readLine())!=null) {
ewXml=ewXml+tempStr;
logger.debug(tempStr);
}
Element root = null;
root = DocumentHelper.parseText(ewXml).getRootElement();
Attribute rootCmd=root.attribute("cmd");
Attribute rootVersion=root.attribute("version");
logger.debug("rootNmae = "+root.getName());
logger.debug("EW'cmd = "+rootCmd.getValue());
logger.debug("EW'version = "+rootVersion.getValue());
Element usrName=root.element("Username");
logger.debug("EW.Username value = "+usrName.getTextTrim());
Element source=root.element("Source");
Attribute sourceUns=source.attribute("uns");
logger.debug("EW.Source'uns£½"+sourceUns.getValue());
Attribute sourceType=source.attribute("type");


Ïà¹ØÎĵµ£º

Parsing XML from the Net Using the SAXParser


Parsing XML from the Net - Using the SAXParser
http://www.anddev.org/parsing_xml_from_the_net_-_using_the_saxparser-t353.html
What you learn:
You will learn how to properly parse XML
(here: from the net
) using a SAXParser
.
What it will look like:
Description:
0.)
In this tutorial we ......

°ÑXMLDocumentת»»³Éxml×Ö·û´®

XMLDocumentÀàÌṩÁ˷ḻµÄÊôÐԺͷ½·¨£¬¿ÉÒÔ°ïÖúÎÒÃÇÇáËÉÍê³ÉxmlµÄ±à¼­¡£µ«ÊÇ£¬Íê³ÉºóµÄxmlºÜ¶àÇé¿öÏ¿ÉÄÜ»¹ÊÇÐèÒªÒÔ×Ö·û´®ÐÎʽ´«µÝ¡£XMLDocumentÓиöSave·½·¨£¬²»½ö¿ÉÒÔ±£´æXMLÎļþÖÁ´ÅÅÌ£¬»¹Äܽ«Æä±£´æÖÁÖ¸¶¨µÄÁ÷£¬È»ºó£¬¾ÍÄÜ´ÓÕâ¸öÁ÷£¨stream£©¶ÁÈ¡ËùÐèÒªµÄ×Ö·û´®ÁË¡£
XmlDocument doc = new XmlDocument();
...
.../ ......

Jasperreportµ¼³öHtml¡¢Pdf¡¢Excel¡¢Rtf¡¢Xml´íÎó»ã×Ü


ת×Ô£ºhttp://lbccheng.blog.163.com/blog/static/314120920095525627390/
ÎÊÌâÒ»£ºÊ¹ÓÃJasperReportÉú³ÉHtml±¨±íºó£¬Êý¾ÝÏÔʾÕýÈ·£¬µ«¸÷ÖÖÏßÌõÏÔʾ²»³öÀ´
           ²úÉúÔ­Òò£ºÔÚ Éú³ÉHTMLÒ³ÃæʱJRHtmlExporterParameter.IMAGES_URI²ÎÊýÉèÖò»ÕýÈ·£¬Ö÷ÒªÊÇͼƬµÄ ......

XML¶ÁдÀ࣬CMarkup

//******************** Í·Îļþ  Markup.h  *******************
// Markup.h: interface for the CMarkup class.
//
// Markup Release 11.2
// Copyright (C) 2009 First Objective Software, Inc. All rights reserved
// Go to www.firstobject.com for the latest CMarkup and EDOM documentation
// ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ