java´´½¨Xml±Ê¼Ç
ÓÃjava´´½¨XmlµÄ4´óÀࣺ
Element£º½ÚµãÀà
AttributeÊôÐÔÀà
Document£ºÖ¸µÄ¾ÍÊÇÎĵµÀà
XMLOutput£ºÊä³öÀà
´ËÀàÊÇÓÃjava½¨Á¢Ò»¸öxmlÎļþ
public class TestJdom {
//´´½¨XML£¨Ä£ÐÍ£©dom
public static void main(String[] args) {
createXmlDom();
}
public static void createXmlDom(){
Element beans=new Element("beans");
Element bean=new Element("bean");
Attribute id=new Attribute("id","dataSource");
Attribute clazz=new Attribute("class","org.apache.commons.dbcp.BasicDataSource");
bean.setAttribute(id);
bean.setAttribute(clazz);
beans.addContent(bean);
Map<String ,String> map=new HashMap<String,String>();
map.put("driverClassName", "com.mysql.jdbc.Driver");
map.put("username", "root");
map.put("password", "root");
map.put("url", "jdbc:mysql://localhost:3306/test");
for(Map.Entry<String,String> mapEntry:map.entrySet()){
Element property=new Element("property");
property.setAttribute("name", mapEntry.getKey());
Element value=new Element("value");
value.setText(mapEntry.getValue());
&nb
Ïà¹ØÎĵµ£º
ÕâÀï×ܽáÒ»ÏÂXMLÎļþµÄ¶Áд¹ý³Ì£¬ÏÈ˵һÏÂдµÄ¹ý³Ì£¬ÕâÀïÎÒÓõÄÊÇXmlDocumentµÄwrite·½·¨ÊµÏֵģ¬Ð´µÄ¹ý³ÌÊDZȽϼòµ¥µÄ£¬Ö»ÐèÒª¶¨Òå×Ô¼ºÏëÒªµÄÔªËØ±äÁ¿£¬
Element user=null;
Element username=null,password=null;
È»ºó
// ¶¨Ò幤³§£¬Ê¹Ó¦ÓóÌÐòÄܹ»´Ó XML Î ......
ÔÎĵØÖ·£ºÎªÁ˱¸Íü£¬×ªÔØ×Ôhttp://www.j2megame.org/index.php/content/view/1989/125.html
1. javaÖжÑÓëÕ»
ÔÚJava³ÌÐòÔËÐÐʱ£¬ÓÐ6¸öµØ·½¿ÉÒÔÓÃÓÚ±£´æÊý¾Ý£º
(1) ¼Ä´æÆ÷¡£×î¿ìµÄ±£´æÇøÓò£¬Î»ÓÚ´¦ÀíÆ÷ÄÚ²¿,ÊýÁ¿Ê®·ÖÓÐÏÞ£¬ËüÊǸù¾ÝÐèÒªÓɱàÒëÆ÷·ÖÅä¡£ÎÒÃǶԴËûÓÐÖ±½ÓµÄ¿ØÖÆÈ¨.
(2)
Õ»(stack)¡£×¤ÁôÓÚ³£¹æRAM£¨Ëæ»ú ......
DECLARE @x xml
SET @x='
<root>
<ShopAccount>
<ActivityType>IA - PM Standing WO (for LPI report)</ActivityType>
<ProjectNo>R</ProjectNo>
</ShopAccount>
<ShopAccount>
......
Êý×飺±íʾ¶¨ÒåͬÖÖÊý¾ÝÀàÐ͵Ķà¸ö±äÁ¿
1.һάÊý×éµÄ¶¨Òå
Êý×éÔªËØµÄÊý×éÀàÐÍ[] Êý×éÃû=new Êý×éÔªËØµÄÊý¾ÝÀàÐÍ[Êý×éÔªËØµÄ¸öÊý] »ò
Êý×éÔªËØµÄÊý¾ÝÀàÐÍ Êý×éÃû[]=new Êý×éÔªË ......