DataTabת»»XML XMLת»»DataTable µÄÀà
public 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);
return System.Text.Encoding.GetEncoding("gb2312").GetString(arr).Trim();
}
catch
{
return String.Empty;
}
finally
{
if (writer != null) writer.Close();
}
}
public 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();
}
}
Ïà¹ØÎĵµ£º
Éú³É¶Ë´¦Àí
½«ÒªÐ´ÈëµÄÖµµÄÇ°ºóдÉÏÈç:"<![CDATA[" + string+ "]]>";
XmlNode xnformchild = doc.CreateNode(XmlNodeType.Element, dc.ColumnName.ToUpper(), "");
try
{
xnformchild.InnerXml = drform[dc.ColumnName].ToString( ......
XML SchemaÖ÷ÒªÓÃÀ´Éè¼ÆXMLÎĵµµÄ½á¹¹£¬×¢Òâ²»ÊǸñʽ¡£ÓÐÈËÎÊÔõô²»ÊǸñʽ£¿¸ñʽ¸ú½á¹¹Ê²Ã´Çø±ð£¿ÎÒÏë¸ã¿ª·¢µÄÈ˶¼¶Ô´úÂë½øÐиñʽ»¯¹ý£¬Ò²¾ÍÊÇËõ½ø¡¢×ÖÌåµÈµÈ£»¶øÎÒÃÇдµÄ³ÌÐòʵ¼ÊÉÏÒ²ÊǶ¨ÒåÒ»Öֽṹ£¬Ëü²»»áÒòΪÄãÊÇ·ñËõ½ø¡¢²ÉÓò»Í¬µÄ×ÖÌå¾ÍÓÐËù¸Ä±ä°É£¿ºÜ¶àÈËÄÄÁ˲»·ÖÐеÄxmlÎĵµËµÓÃVSµÄ¹¤¾ß¸ ......
Ò»°ãÐÂÊÖͨ³£Ö»ÊÇʹÓÃÀàËƵÄXerces,
TinyXMLÖ®ÀàµÄXML½âÎöxml£¬ÕâÖÖ·½Ê½Êµ¼ÊÉϺÜÀË·Ñʱ¼ä£¬×Ô¼º±àдºÜ¶à´úÂëÒ²ÈÝÒ׳ö´í¡£ÒòΪ£¬ËûÃǾ³£ÒªÐ´Ò»¸öXML¶ÔÏóEntityµÄÀ࣬²¢¸½×ÅÒ»¶Ñ¶ÔÏó½âÎöµÄcode¡£¹¤×÷Á¿±È½Ï´ó¡£Ê¹ÓÃXML
Schema¹¤¾ß£¬XSDÉè¼Æ¹¤¾ß£¬È»ºóͨ¹ý¹¤¾ßÉú³ÉEntityClassºÍPaser
class¡£ÎÒ²»ÖªµÀÕâÖÖ¼¼ÊõÈ·ÇеÄÆðÔ ......
³£³£ÔÚÍøÉÏ¿´µ½Ò»Ð©ºÜµÄFLASHЧ¹û¿ÉÊÇÏÂÏÂÀ´ºó²Å·¢ÏÖÖÐÎIJ»Ö§³Ö»ò¶¼ÖÐÎÄÎÞ·¨ÏÔʾµÄÎÊÌ⣬ËùÒÔÔÚÍøÉÏÕÒÁ˺ܶà×ÊÁÏÖÕÓÚÕÒµ½ÁËÒ»¸ö¼òµ¥µÄ·½·¨À´½â¾öÕâ¸öÎÊÌ⣬ÔÚÕâÀïÓë´ó¼Ò·ÖÏíһϡ£
µãÄÏǶÈë°´Å¥£¬°´ÏÂctrlÑ¡Öдóд,Сд,Êý×Ö,±êµã·ûºÅ,ÖÐÎÄ(È«²¿)ºó,È·¶¨!!
ÕâÑù¾ÍOKÁË¡£ ......
C#ÐòÁл¯xml
¹Ø¼ü²½Ö裺
XmlSerializer xSerializer = new XmlSerializer(typeof(MyObj));
StringWriter sWriter = new StringWriter(CultureInfo.InvariantCulture);
XmlTextWriter xTextWriter = new XmlTextWriter(sWriter);
......