XML 实体引用
在 XML 中,一些字符拥有特殊的意义。
如果你把字符 "<" 放在 XML 元素中,会发生错误,这是因为解析器会把它当作新元素的开始。
这样会产生 XML 错误:
<message>if salary < 1000 then</message>
为了避免这个错误,用一个实体引用来代替 "<" 字符:
<message>if salary < 1000 then</message>
在 XML 中,有 5 个预定义的实体引用:
<
<
小于
>
>
大于
&
&
和号
'
'
单引号
"
"
引号
注释:在 XML 中,只有字符 "<" 和 "&" 确实是非法的。大于号是合法的,但是用实体引用来代替它是一个好习惯。
相关文档:
Retrieving an XML document using Ajax
http://www.javascriptkit.com/dhtmltutors/ajaxgetpost3.shtml
When making a server request in Ajax, the data returned can be in either
plain text/html, or an XML document instead. The later is technically
just a text file as well, but with s ......
Create:
int nFQ;
XmlDocument doc = new XmlDocument();
XmlAttribute
newAtt;
//定义XML文档头文件
XmlDeclaration dec =
doc.CreateXmlDeclaration("1.0",null,null);
doc.AppendChild(dec);
&n ......
写本文的目的是为了方便大家了解C++ MSXML操作方法。
当然,C++中对MSXML的调用有多种,本文采用的方法是完全参照MSXML SDK提供的文档进行操作。
如果有什么错误,欢迎指正。
代码框架是基于vs2008 MFC 对话框程序(UNICODE)。对话框程序需要读者自己创建。
#include <msxml6.h>
#include <comutil.h>
# ......
在XML文件中读取属性文件(.properties)中的元素值:
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/conf/dataAccessContext.xml</param-value>
</context-param>
<listener>
<listener-class>
......
方法一:
采取通用的base64编码方式,取时解码存时加码。
毛老师提供了完整的编码代码,且效率很高。
unit Base64;
interface
uses SysUtils, Classes;
type
{$IFDEF UNICODE}
Base64String = AnsiString;
{$ELSE}
Base64String = strin ......