DataSet(DataTable)ÓëXML»¥×ª
using System;
using System.Data;
using System.IO;
using System.Xml;
using System.Text;
// ÏàÓ¦C#´úÂ룺
private string ConvertDataTableToXML(DataTable xmlDS)
{
MemoryStream stream = null;
XmlTextWriter writer = null;
try
{
stream = new MemoryStream();
writer = new XmlTextWriter(stream, Encoding.Default);
xmlDS.WriteXml(writer);
int count = (int)stream.Length;
byte[] arr = new byte[count];
stream.Seek(0, SeekOrigin.Begin);
stream.Read(arr, 0, count);
UTF8Encoding utf = new UTF8Encoding();
return utf.GetString(arr).Trim();
}
catch
{
return String.Empty;
}
finally
{
if (writer != null) writer.Close();
}
}
private DataSet ConvertXMLToDataSet(string xmlData)
{
StringReader stream = null;
XmlTextReader reader = null;
try
{
DataSet xmlDS = new DataSet();
stream = new StringReader(xmlData);
reader = new XmlTextReader(stream);
xmlDS.ReadXml(reader);
return xmlDS;
}
catch (Exception ex)
{
string strTest = ex.Message;
return null;
}
finally
{
if (reader != null)
reader.Close();
}
}
Ïà¹ØÎĵµ£º
ÒÔǰÔÚ²©¿ÍÉÏ·¢¹ý£¬¾ÈËÌáÐÑDataSetÒÑ×Ô´ø¶ÁдXMLµÄ¹¦ÄÜ£¬ÓÚÊDZãɾÁË£¬
²»¹ýÔÚʵ¼ùÖиоõ·â×°Ò»²ãºó£¬Ê¹ÓÃÆðÀ´»¹ÊÇÂù·½±ãµÄ¡£¹ÊÔÙ´ÎÖØ·¢¡£
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.IO;
using System.Xml;
namespace XmlDesign
{
class XmlDatasetC ......
VC++ÖвÙ×÷XML£¨MFC¡¢SDK£©
2009Äê01ÔÂ07ÈÕ ÐÇÆÚÈý 22:33
XMLÔÚWin32³ÌÐò·½ÃæÓ¦¸ÃûÓÐÔÚWeb·½ÃæÓ¦Óõö࣬ºÜ¶à
Win32³ÌÐòÒ²Ö»ÊÇÓÃXMLÀ´´æ´æÅäÖÃÐÅÏ¢¶øÒÑ£¬¶øÇÒûÓÐ×ã¹»
µÄºÃ´¦µÄ»°»¹²»ÈçÓà ini¡£VC++Àï²Ù×÷XMLÓÐÁ½¸ö¿â¿ÉÒÔÓãº
MSXMLºÍXmlLite¡£MSXMLÓÖϸ·ÖÁËÁ½ÖÖ½Ó¿Ú£ºDOMºÍSAX2¡£XPû×Ô´øÓÐ XmlLite£¬Ö»×Ô´øÓÐ2.x¡¢3 ......
¿ª·¢Öо³£Óöµ½ÒªºÍ¸÷ÖÖ¸÷ÑùµÄ XML ´ò½»µÀ£¬±à¼ XML Îļþʱ×îÍ·Í´µÄ±ãÊÇÒª¼ÇסÐí¶à XML ÔªËØÃû³Æ¡¢ÊôÐÔÃû³Æ¡£
ÐÒÔ˵ÄÊÇ£¬Vistual Studio µÄ XML ÖÇÄÜÌáʾ¹¦ÄÜ¿ÉÒÔ´ó´óµØ¼õÇáÕâһʹ¿à¡£Ö»Ðèͨ¹ýÌí¼Ó×Ô¶¨ÒåµÄ XSD ÎļþʹµÃÔڱ༠XML Îļþʱ»ñµÃV ......
XML DOM
XML DOM (XML Document Object Model) ¶¨ÒåÒ»Ì×·ÃÎʺͲÙ×÷ XML ÎĵµµÄ±ê×¼·½·¨¡£
DOM °Ñ XML Îĵµ×÷ΪÊ÷½á¹¹À´²é¿´¡£Äܹ»Í¨¹ý DOM Ê÷À´·ÃÎÊËùÓÐÔªËØ¡£¿ÉÒÔÐ޸Ļòɾ³ýËüÃǵÄÄÚÈÝ£¬²¢´´½¨ÐµÄÔªËØ¡£ÔªËØ£¬ËüÃǵÄÎı¾£¬ÒÔ¼°ËüÃǵÄÊôÐÔ£¬¶¼±»ÈÏΪÊǽڵ㡣
ÔÚÏÂÃæµÄÀý×ÓÖУ¬ÎÒÃÇʹÓà DOM ÒýÓÃ´Ó <to> ÔªËØÖлñÈ ......
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
xmlѧϰ£ºhttp://www.w3school.com.cn/x.asp ......