更新时间:2022-12-18 09:54:32
Hush写道:
Hush wrote:
以下代码在IE7中正常工作但FF返回错误:
访问被拒绝实现Element.firstChild属性。在这个
行:
nodes = xmlDoc.documentElement.childNodes;
The following code works fine in IE7 but FF returns with an error:
Access denied to achieve the property Element.firstChild. In this
line:
nodes = xmlDoc.documentElement.childNodes;
在表达式'/ b $ b'中,'firstChild''不会出现错误,该表达式不包含该名称。
It is not likely that you get an error on ''firstChild'' in an expression
that does not contain that name.
函数handleXML()
{
nodes = xmlDoc.documentElement.childNodes;
alert(nodes.item(0).text);
//
alert(xmlDoc.getElementsByTagName(''nick'')。childNod es.firstChild.nodeValue);
function handleXML()
{
nodes = xmlDoc.documentElement.childNodes;
alert(nodes.item(0).text);
//
alert(xmlDoc.getElementsByTagName(''nick'').childNod es.firstChild.nodeValue);
表达式没有意义,getElementsByTagName给出了一个可以索引的
集合,而childNodes给出了一个集合
你也可以索引。
我认为你应该向我们展示你加载的XML并描述你想要读出的元素
然后我们可以帮助编码访问这些元素。
-
Martin Honnen
http://JavaScript.FAQTs.com/
8月7日,14日:41,Martin Honnen< mahotr ... @ yahoo.dewrote:
On 7 Aug., 14:41, Martin Honnen <mahotr...@yahoo.dewrote:
Hush写道:
Hush wrote:
以下代码在IE7中正常工作但FF返回错误:
The following code works fine in IE7 but FF returns with an error:
访问被拒绝以实现属性Element.firstChild。在这个
行:
* nodes = xmlDoc.documentElement.childNodes;
Access denied to achieve the property Element.firstChild. In this
line:
*nodes = xmlDoc.documentElement.childNodes;
在表达式'/ b $ b'中,'firstChild''不会出现错误,该表达式不包含该名称。
It is not likely that you get an error on ''firstChild'' in an expression
that does not contain that name.
对不起,我打错了。当然Access拒绝实现
属性Element.childNodes,而不是firstNode。
Sorry, I typed it wrong. Its of course Access denied to achieve the
property Element.childNodes, and not firstNode.
表达式没有意义,getElementsByTagName给出一个
集合,你可以索引,而childNodes给你一个集合,你可以索引
。
我认为你应该向我们展示XML你加载并描述你要读出的元素
,然后我们可以帮助编码对这些元素的访问。
That expression does not make sense, getElementsByTagName gives a
collection which you can index, and childNodes gives a collection which
you can index too.
I think you should show us the XML you load and describe the elements
you want to read out, then we can help coding the access to those elements.
好的。实际上我只想提取1个数字(1或0)所以我只需要XML中的1
值。我的XML如下:
<?xml version =" 1.0" encoding =" iso-8859-1"?>
< nick>
< isa> 0< / isa>
< / nick>
我正在尝试获取元素的值< isa>
Hush
Ok. Actually I only want to extract 1 number (1 or 0) so I only need 1
value from the XML. My XML is as follows:
<?xml version="1.0" encoding="iso-8859-1"?>
<nick>
<isa>0</isa>
</nick>
I''m trying to get the value of the element <isa>
Hush
Hush写道:
Hush wrote:
好的。实际上我只想提取1个数字(1或0)所以我只需要XML中的1
值。我的XML如下:
<?xml version =" 1.0" encoding =" iso-8859-1"?>
< nick>
< isa> 0< / isa>
< / nick>
我正在尝试获取元素的值< isa>
Ok. Actually I only want to extract 1 number (1 or 0) so I only need 1
value from the XML. My XML is as follows:
<?xml version="1.0" encoding="iso-8859-1"?>
<nick>
<isa>0</isa>
</nick>
I''m trying to get the value of the element <isa>
var isaElements = xmlDoc.getElementsByTagName(''isa'');
if(iseElements.length 0)
{
var isa = isaElements [0];
var n = isa.firstChild.nodeValue;
}
else
{
//处理未找到'isa'元素的案例
}
假设''isa''元素中总有一些文字。
-
Martin Honnen
http://JavaScript.FAQTs.com/