在JS中解析的Xml内容 [英] Xml content parsed in JS

查看:63
本文介绍了在JS中解析的Xml内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我的脚本以字符串形式获取XML文件的内容,感谢

到Ajax。

我想将XML内容转换为HTML表格。

如果没有在JS中编写整个XML解析器,有没有简单的方法呢?


提前致谢,


-

pierre

Hello,

My script gets the content of an XML file in a string of characters thanks
to Ajax.
I''d like to transform the XML content to an HTML table.
Is there an easy way to do so without coding a whole XML parser in JS ?

Thanks in advance,

--
pierre

推荐答案

pierre写道:

pierre wrote:


我的脚本以字符串形式获取XML文件的内容,感谢

到Ajax。

我想将XML内容转换为HTML表格。

如果没有在JS中编写整个XML解析器,有没有一种简单的方法可以做到这一点?
My script gets the content of an XML file in a string of characters thanks
to Ajax.
I''d like to transform the XML content to an HTML table.
Is there an easy way to do so without coding a whole XML parser in JS ?



这应该不是问题,但代码依赖于XML文件的结构。你能发贴吗?


-

巴特

That shouldn''t be a problem, but the code depends on the structure of
the XML file. Could you post it ?

--
Bart




pierre写道:



pierre wrote:


我的脚本以字符串形式获取XML文件的内容,谢谢

到Ajax。

我想将XML内容转换为HTML表格。

有没有编码的简单方法JS中的整个XML解析器?
My script gets the content of an XML file in a string of characters thanks
to Ajax.
I''d like to transform the XML content to an HTML table.
Is there an easy way to do so without coding a whole XML parser in JS ?



Ajax?好吧,这并不能说明你使用的代码和API。如果你使用XMLHttpRequest

那么它已经对服务器内置的

响应提供XML解析支持,只需确保服务器发送

回答XML MIME类型作为Content-Type标题,例如

内容类型:application / xml



内容类型:text / xml

和XMLHttpRequest将响应体解析为XML并填充

requestObject.responseXML作为XML DOM文档,您可以使用DOM编写脚本

方法(DOM Level 2 Core和XML,一些DOM Level 3 Core,DOM Level 3

XPath with Mozilla或Opera 9,DOM Level 1 XML with IE / MSXML

MSXML 3及更高版本支持XPath的一些MSXML特定内容。


-


Martin Honnen
http://JavaScript.FAQTs.com/


这应该不是问题,但代码取决于结构
的重新
That shouldn''t be a problem, but the code depends on the structure of

XML文件。你能发贴吗?


-

Bart
the XML file. Could you post it ?

--
Bart



这是我的Xml内容:


< MyData>

< Columns>

< Column> Id< / Column>

<列>名称< /列>

< /列>

<行>

<行>

< Id> 1< / Id>

<名称>彼得< /名称>

< / Row>

< Row>

< Id> 2< / Id>

< Name> John< / Name>

< / Row>

< / Rows>

< / MyData>


提前感谢,


-

larry

This is my Xml content :

<MyData>
<Columns>
<Column>Id</Column>
<Column>Name</Column>
</Columns>
<Rows>
<Row>
<Id>1</Id>
<Name>Peter</Name>
</Row>
<Row>
<Id>2</Id>
<Name>John</Name>
</Row>
</Rows>
</MyData>

thanks in advance,

--
larry


这篇关于在JS中解析的Xml内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆