Retrieves a reference to the XML Document Object Model (DOM) exposed by the object.
dhtml语法
XML | N/A |
---|
Scripting | [ oXMLObject = ] object.XMLDocument |
---|
DHTML可能的值
oXMLObject | Objectthat specifies the XML DOM exposed by the object. |
The property is read-only.
The property has no default value.
Remarks
For a complete description of the XML DOM exposed by the XMLDocument property, see the xml dom reference.
when persistence is applied to an element, a root node is automatically created within the exposed xml document. this node is accessed through the documentelement property. you can use setattribute to add attributes to the root node, and you can use appendchild to add child nodes to the root node.
the xmldocument property is available to the savefavorite and savehistory behaviors only when the onload and onsave events are fired.
DHTML代码范例
This example shows how a persistent object can access the XML DOM through the XMLDocument property. The setAttribute method is exposed through the XML DOM. The setAttribute method is not the same as the DHTML and persistence methods of the same name.
<HTML>
<HEAD>
<META NAME="save" CONTENT="history">
<STYLE>
.saveHistory {behavior:url(#default#savehistory);}
</STYLE>
<SCRIPT>
function fnSave(){
var oXMLDoc=oPersistObject.XMLDocument;
var oNode=oXMLDoc.createNode(1,"Trunk", "");
oNode.text="A tree trunk.";
oNode.setAttribute("desc",oPersistObject.innerHTML);
oXMLDoc.documentElement.insertBefore(oNode, null);
}
function fnLoad(){
var oXMLDoc=oPersistObject.XMLDocument;
var oItem=oXMLDoc.documentElement.childNodes.item(1);
oPersistObject.innerHTML=oItem.getAttribute("desc");
}
function fnInsTxt(){
oPersistObject.innerHTML="I am an Ash. I am an Ash sapling."
+ "Well, I am the trunk of an Ash sapling.";
}
</SCRIPT>
</HEAD>
<BODY>
<INPUT TYPE="button" VALUE="Insert Text" ONCLICK="fnInsTxt()">
<A href="#workshop/samples/author/persistence/savetarget_1.htm">
Leave The Page
</A>
<DIV
ID="oPersistObject"
CLASS="saveHistory"
ONSAVE="fnSave()"
ONLOAD="fnLoad()">
</DIV>
</BODY>
</HTML>
This feature requires Microsoft® Internet Explorer 5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.
是否符合公共标准
There is no public standard that applies to this property.
Applies To
更多语法参考
Introduction to Persistence