String to XML Document

未知
未知
2008-09-19

I created a very basic function which allows you to convert XML in a string type, into an XML Document type, which gives you the benefits of XML with AJAX.

I'll write up a better explanation another time, as well as submit some other useful data conversion functions

<script type="text/javascript">
// Name: createXMLDocument
// Input: String
// Output: XML Document
jQuery.createXMLDocument = function(string)
{
var browserName = navigator.appName;
var doc;
if (browserName == 'Microsoft Internet Explorer')
{
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false'
doc.loadXML(string);
} else {
doc = (new DOMParser()).parseFromString(string, 'text/xml');
}
return doc;
}
</script>

Usage:

<script type="text/javascript">
var text = '<message><from>me</from><to>you</to></message>';
var doc = $.createXMLDocument(text);
</script>

加载中

评论(0)

暂无评论

暂无资讯

4
回答
xml模版里的数据 导入mysql怎么弄??

<?xml version="1.0" encoding="utf-8"?> <root> <Sentences> <name>DR</na...

2015/06/29 09:56
2
回答
xml,怎么通过dom用java读取出item的值
卖豆浆不卖油条 的回答 2012/08/16 14:41
最佳答案
nodeList.item(0).getChildNodes(); 问题出在这句,getChildNodes()不知道可不可以加个参数来指定item。 我解析xml一般用jsoup,这个比dom4j好用多了。
1
回答
string用dom写入xml会被转义,怎么不转义呢?

java,想把 String s = “Visible to all nearby Bluetooth devices (<xliff:g id="dis...

2012/08/09 14:46

没有更多内容

加载失败,请刷新页面

没有更多内容

暂无博客

返回顶部
顶部