请教:DOM中,Element的tagName的属性是否只读?

这是我的例子:
----------------------

1<xml id="zxml">   
2&lt;元素&gt;   
3&lt;子元素&gt;内容<!--子元素-->
4<!--元素-->
5</xml>
 1<html>
 2<head>
 3<script>   
 4  
 5var xmlDoc=document.all("zxml").XMLDocument;   
 6var newNode=xmlDoc.createElement("新元素");   
 7newNode.text="新内容";   
 8window.alert(newNode.xml);   
 9//newNode.tagName="aaaaa";//去掉这句的注释就报错   
10window.alert(newNode.xml);   
11  
12</script>
13</head>
14</html>

---------------------------------
说明tagName不能修改。但我在vs.net的帮助中摘录的一段, 该如何解释?
-------------------------------------
位置:XML General Technical Articles

主题:The XML Object Model in Internet Explorer 4.0

tagName
Description:

Returns the name of the tag as a string. The name is always in uppercase. The name of a comment element is returned as "!". The other META tags have names that correspond to the special character followed by the META tag name. For instance, the name of

is "?XML". Prototype: elem.tagName Example: if (elem.type == 0) //if it is a tag return elem.tagName; //return the tag name as a string Note It is also possible to change a tag name by assigning a value to that property: if (elem.tagName == "PAINTING") //if a element elem.tagName = "OIL-PAINTING"; //change its tag name to "OIL-PAINTING" \------------------------------------------------------------------------- 若tagName真的是只读的,我还有什么办法修改它呢? \--------------------------------------------------------------- you are using MSXML, here is from MSXML4 documentation: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/xml_pro_sz_21wl.asp tagName Property Contains the element name. ... Remarks String. The property is read-only. It contains the string that represents the element's name. \--------------------------------------------------------------- tagName是只读的。 更改它可以先删了它,再添加你要的。
Published At
Categories with Web编程
Tagged with
comments powered by Disqus