dataset写xml的问题 2004-12-29, 04:09 下午
dataset写xml的问题feng


dataset写xml的问题
等级: 新手上路
注册: 2004-11-03
发贴: 2
问个dataset写xml的问题,高手进来看下。

一个dataset,想写成xml格式。

Ds.WriteXml(Path);

问题是ds中列Content我保存的是html数据,回写的时候都转换成了<>之类的了。

我现在想写成的xml还是保存成html内容,也就是说不进行转换,该怎么操作:

这是用WriteXml生成的数据。

<?xml version="1.0" standalone="yes"?>
<Text>
  <Reply>
    <ID>670006</ID>
    <Link>&lt;br&gt;&lt;Br&gt;</Link>
  </Reply>
</Text>

这是我希望生成的数据:
<?xml version="1.0" standalone="yes"?>
<Text>
  <Reply>
    <ID>670006</ID>
    <Link><![CDATA[<br><Br>]]></Link>
  </Reply>
</Text>

那dataset写xml的时候,该如何操作,如何指定某列用CDATA方式写入???


dataset写xml的问题 IP 地址: 已记录    
 dataset写xml的问题 2004-12-30, 11:55 上午
dataset写xml的问题Lion


dataset写xml的问题
等级: 新手上路
注册: 2004-10-31
发贴: 48
Re: 问个dataset写xml的问题,高手进来看下。
void test()
  {
   System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
   doc.LoadXml("<root>"+
    "  <pagesetting>"+
    "    <Landscape>false</Landscape>"+
    "    <paperkind>A4</paperkind>"+
    "  </pagesetting>"+
    "  <reporttable>"+
    "  </reporttable>"+
    "</root>");
   System.Xml.XmlComment newComment;
   newComment = doc.CreateComment("RemotePrint XML document");
 
   //Create a xml declaration.
   System.Xml.XmlDeclaration xmldecl;
   xmldecl = doc.CreateXmlDeclaration("1.0",null,null);
   xmldecl.Encoding="GB2312";
   xmldecl.Standalone="yes";
  
   System.Xml.XmlElement root = doc.DocumentElement;
   doc.InsertBefore(xmldecl, root);
   doc.InsertBefore(newComment, root);
   //
   System.Xml.XmlNode reporttable = doc["root"]["reporttable"];
   reporttable.AppendChild(doc.CreateCDataSection("<br />测试<span style=\"color:blue;\">数据</span><br />"));
   doc.Save(Server.MapPath("test.xml"));
  }

-------------------------------------------------
<?xml version="1.0" encoding="GB2312" standalone="yes"?>
<!--RemotePrint XML document-->
<root>
  <pagesetting>
    <Landscape>false</Landscape>
    <paperkind>A4</paperkind>
  </pagesetting>
  <reporttable><![CDATA[<br />测试<span style="color:blue;">数据</span><br />]]></reporttable>
</root>

相关文章:

  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
  • 2021-08-22
  • 2021-10-19
  • 2022-12-23
猜你喜欢
  • 2021-08-12
  • 2021-09-04
  • 2021-07-01
  • 2021-09-28
  • 2021-08-14
相关资源
相似解决方案