grails½âÎöxmlÎļþ
xmlÎļþ£º
<?xml version="1.0" encoding="iso-8859-1"?>
<Products>
<product>
<name>lovechoosesun</name>
<buyNowURL>http://merch.danecook.com/ProductDetails.asp?ProductCode=DC101</buyNowURL>
<imageUrl>http://merch.danecook.com/v/vspfiles/photos/DC101-1.jpg</imageUrl>
<status>ACTIVE</status>
<description>desc1</description>
<price>12.0</price>
<dateCreated>2009-12-30 14:07:46</dateCreated>
<lastUpdated>2009-12-30 14:07:46</lastUpdated>
</product>
<product>
<name>zhaoweisun</name>
<buyNowURL>http://merch.danecook.com/ProductDetails.asp?ProductCode=DC101</buyNowURL>
<imageUrl>http://merch.danecook.com/v/vspfiles/photos/DC101-1.jpg</imageUrl>
<status>ACTIVE</status>
<description>desc2</description>
<price>13.5</price>
<dateCreated>2009-12-30 14:07:46</dateCreated>
<lastUpdated>2009-12-30 14:07:46</lastUpdated>
</product>
</Products>
action£º
def saveRealGifts = {
def products = new XmlParser().parse("Products.xml"
Ïà¹ØÎĵµ£º
public string WriteXML(string[] values, int flag)
{
//Èç¹ûflag==0ÔòΪµÚÒ»´ÎÔËÐÐÐèÒª³õʼ»¯XMLÎļþ
if (flag == 0)
{
//ÉúÔÚËæ»úÎļþÃû
string dateName = System.DateTime.Now.ToString("yyyyMMddHHmmss");
......
TinyXML£ºÒ»¸öÓÅÐãµÄC++ XML½âÎöÆ÷
¶ÁÈ¡ºÍÉèÖÃxmlÅäÖÃÎļþÊÇ×î³£ÓõIJÙ×÷£¬ÊÔÓÃÁ˼¸¸öC++µÄXML½âÎöÆ÷£¬¸öÈ˸оõTinyXMLÊÇʹÓÃÆðÀ´×îÊæ·þµÄ£¬ÒòΪËüµÄAPI½Ó¿ÚºÍJavaµÄÊ®·ÖÀàËÆ£¬ÃæÏò¶ÔÏóÐԺܺá£
TinyXMLÊÇÒ»¸ö¿ªÔ´µÄ½âÎöXMLµÄ½âÎö¿â£¬Äܹ»ÓÃÓÚC++£¬Äܹ»ÔÚWindows»òLinuxÖбàÒë¡£Õâ¸ö½âÎö¿âµÄÄ£ÐÍͨ¹ý½âÎöXMLÎļþ£¬È»ºóÔ ......
// TestXml.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include "tinyxml.h"
#include "lang.h"
#include <string>
using namespace std;
using namespace std;
#pragma comment(lib, "tinyxmld.lib")
B ......
ÕâÆªÎÄÕÂÃèÊöÈçºÎͨ¹ýʹÓÃFOR XML AUTO¸üºÃµÄ¿ØÖÆXMLÊä³ö¸ñʽ¡£ÀýÈçÌí¼ÓXML±ê¼Ç¡£ÓÃÕâ¸öÀ´Ìæ´úÄÑÓÚÀí½âµÄFOR XML EXPLICIT Óï¾ä¡£Èç¹ûÄãÔÚÓ¦ÓóÌÐòÖм´½«·´ÐòÁл¯Êä³öµÄXML£¬Äã¾Í»á¾õµÃÕâ¸öÐÅÏ¢¶ÔÄãÓÐÓá£
ÔÚFor XML´Ó¾äÖУ¬Äúͨ³£Ê¹ÓÃÏÂÁз½Ê½Ö®Ò»£º
RAW
AUT ......
1¡¢Ê×ÏÈÏÂÔØ xstream.jarºÍjettison.jar£¨×ª»»ÎªjsonʱÓõ½£©£¬²¢ÒýÈë¸Ã°ü¡£
2¡¢¿´ÈçÏ´úÂë°É£º
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
import c ......