把XMLDocument转换成xml字符串
XMLDocument类提供了丰富的属性和方法,可以帮助我们轻松完成xml的编辑。但是,完成后的xml很多情况下可能还是需要以字符串形式传递。XMLDocument有个Save方法,不仅可以保存XML文件至磁盘,还能将其保存至指定的流,然后,就能从这个流(stream)读取所需要的字符串了。
XmlDocument doc = new XmlDocument();
...
...//生成xml的代码
实例化一个流,并将生成的XMLDocument保存在其中:
MemoryStream stream = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(stream, null);
writer.Formatting = Formatting.Indented;
doc.Save(writer);
声明一个StreamReader,用于读取刚才那个Stream中的数据到一个字符串变量
StreamReader sr = new StreamReader(stream, Encoding.UTF8);
stream.Position = 0;
string XMLString = sr.ReadToEnd();
sr.Close();
stream.Close();
********
相关文档:
首先写一个html页面userxmlajax.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户校验ajax实例</title>
&nbs ......
转自:http://www.w3school.com.cn/xml/xml_syntax.asp
XML 的语法规则很简单,且很有逻辑。这些规则很容易学习,也很容易使用。
所有 XML 元素都须有关闭标签
在 HTML,经常会看到没有关闭标签的元素:
<p>This is a paragraph
<p>This is another paragraph
在 XML 中,省略关闭标签是非法的。所有元 ......
<?xml version="1.0" standalone="yes"?>
<imgs>
<pic name="/adv_pic/1.jpg" url="http://www.baidu.com/" title="test" />
<pic name="/adv_pic/2.jpg" url="http://www.baidu.com/" title="test" />
......
Parsing XML from the Net - Using the SAXParser
http://www.anddev.org/parsing_xml_from_the_net_-_using_the_saxparser-t353.html
What you learn:
You will learn how to properly parse XML
(here: from the net
) using a SAXParser
.
What it will look like:
Description:
0.)
In this tutorial we ......
FusionCharts 的 XML标签属性有一下四种数据类型
* Boolean - 布尔类型,只能为1或者0。例如:<graph showNames=’1′ >
* Number - 数字类型,只能为数字。例如:<graph yAxisMaxValue=’200′ >
* String - 字符串类型,只能为字符串。例如: <graph caption=’My Chart&rsqu ......