易截截图软件、单文件、免安装、纯绿色、仅160KB

过滤xml中的非法字符串


一般xml中如果含有&等字符,可以通过CDATA来过滤,但是含有一些不认识的特殊字符时候就会不起作用,下面是从别人那儿拿来的一个过滤方
法,过滤xml中的非法字符:
//XML标准规定的无效字节为:
/*
0×00 – 0×08
0×0b – 0×0c
0×0e – 0×1f
*/
//所以很简单,输出的时候过滤这些字符就万无一失了,下面是PHP的实现。
/* PHP 实现 */
function XmlSafeStr($s)
{
return preg_replace(“/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/”,”,$s);
}
W3C的XML规范中关于字符的定义请参看这里:http://www.w3.org/TR/2004/REC-xml-20040204
/#charsets。
过滤非法字符对应的Java版本如下:
public
String
filter(
String
s)
{
return
s.replaceAll
(
"[\\
x00-\\
x08\\
x0b-\\
x0c\\
x0e-\\
x1f]"
, ""
)
;
}


相关文档:

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, E ......

JSP中使用XML实现弹出式菜单

应用JSP,XML和CSS技术实现弹出式菜单的工程框架。
  综合采用JSP,JavaBean,XML,XSL,CSS,JavaScript多项技术的优点。
  在JSP中使用XML文档,XML定义数据格式,在JSP中直接生成XML文件,它与JavaBean交互,JavaBean负责读取存储菜单项的文件。
XSL实现XML到HTML的转化,CSS文件负责样式单的定义,而JavaS ......

sql2005中一个xml聚合的例子

sql2005中一个xml聚合的例子 收藏
该问题来自论坛提问,演示SQL代码如下
--建立测试环境
set nocount on
create table test(ID varchar(20),NAME varchar(20))
insert into test select '1','aaa'
insert into test select '1','bbb'
insert into test select '1','ccc'
insert into test select '2','ddd'
inser ......

XMLHttpRequest 异步处理XML典型应用

声明对象实例
var xmlhttp = false;
//产生一个XMLHttpRequest对象实例
getHTTPRequestObject();
function getHTTPRequestObject()
{
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp = new ActiveXObject("Micr ......

Xml Schema

Standards
"DTD" was the first formalized standard, but is rarely used anymore.
"XDR" was an early attempt by Microsoft to provide a more comprehensive standard than DTD. This standard has pretty much been abandoned now in favor of XSD.
"XSD" is currently the de facto standard for describing XML d ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号