Ìí¼ÓXML½Úµã
Ìí¼ÓXML½Úµã
/// <summary>
/// ³õʼ»¯XML status-0
/// </summary>
/// <returns></returns>
private bool InitialConfig()
{
bool bRet = false;
try
{
PatchID = Guid.NewGuid().ToString();
string dirXml = ConfigurationManager.AppSettings["xmlFilePath"];
XmlDocument doc = new XmlDocument();
doc.Load(dirXml);
XmlNode rootNode = doc.DocumentElement;
//XmlNode dataInfo = rootNode.SelectSingleNode("/DataInfo") as XmlNode;
XmlElement decompress = doc.CreateElement("Decompress");
decompress.SetAttribute("PatchID", PatchID);
XmlElement status = doc.CreateElement("Status");
status.InnerText = "0";
XmlElement createDate = doc.CreateElement("CreateDate");
createDate.InnerText = DateTime.Now.ToString();
decompress.AppendChild(status);
decompress.AppendChild(createDate);
 
Ïà¹ØÎĵµ£º
package com.kiloway.trace.utils;
import java.lang.reflect.Field;
/**
* @author Zhang Qi
* @Create Time 2010/01/09
* */
public class ObjectToXML {
public String toString(Object object) throws Exception {
StringBuilder sb = new StringBuilder();
//µÃµ½ÀàµÄÃû³Æ
String classname = obj ......
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax ......
<?xml version="1.0" encoding="utf-8"?>
<userdata createuser="false">
<dataconnection>
<server>xml test</server>
<uid>sa</uid>
<pwd>sa</pwd>
</dataconnection> ......
¼ÙÉèxmlÎļþÊÇ
<?xml version="1.0" encoding="gb2312" ?>
- <books auth="wren">
- <book id="B01">
<name>¹þÀﲨÌØ </name>
<price>10 </price>
<memo>ÕâÊÇÒ»±¾ºÜºÃ¿´µÄÊé¡£ </memo>
</book>
- <boo ......
XmlDocument doc = new XmlDocument();
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "GB2312", null);
doc.AppendChild(dec);
//´´½¨Ò»¸ö¸ù½Úµã£¨Ò»¼¶£©
XmlElement root = doc.CreateElement("First");
doc.AppendChild(root);
//´´½¨½Úµã£ ......