Retrieving Individual Markup Objects - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
}
}
function getElementsOfDoc( item, node )
{
if( item.childNodes.length > 0 )
{
}
}

Retrieving individual markup objects

The first step in retrieving any of the document's elements is to obtain the root of the document's markup
tree. If the document is displayed in a document window, you can get the root object of the markup tree
from the document object's documentElement property:
var tree = document.documentElement();
This returns a markup object for the root element, the virtual <GoLiveMarkup > element. This object
provides access to the rest of the document's content.
You can retrieve the markup object for any SDK-defined element by name. Standard HTML tags do not
provide a name property, so you retrieve the corresponding object by type. An extension that
batch-processes all the files in a site might need to retrieve elements by type; for example, it could modify
the content of every <H1> element in the site.
A page's visible components are subelements of its body element. You can use the
method of the root element object to retrieve a page's <body> subelement by tag name, for example:
// retrieve current page's <body> element
var bodyElt = document.documentElement.getSubElement("body");
This returns the element object for the displayed document's <body> element.
Note:
Even though JavaScript is case-sensitive, the argument to the getSubElement method is not. For
example, this code retrieves the body element object, regardless of whether a <BODY> or <body>
tag defines it.
The getSubElement and getSubElementCount methods can also retrieve elements by tag type. The
tagType argument can be any string that is a valid type attribute of <jsxelement> . The "plain" ,
"binary" and "container" types search for HTML or XML tags; for a complete list of types, see the
GoLive CS2 SDK Programmer's Reference. For example, to search for the first comment tag in a document:
document.getSubElement ("", 0, "!—");
When you supply the tagType argument, the tagName argument is ignored.
var masterroot = treePalette.objTree.value;
for( var i=0; i<item.childNodes.length; i++ )
{
var subitem = item.childNodes[i];
var subnode = masterroot.createNode();
subnode.text = subitem.toString();
node.appendChild( subnode );
getElementsOfDoc( subitem, subnode );
}
Adobe GoLive CS2 SDK
Editing Documents Programmatically
getSubElement
105

Advertisement

Table of Contents
loading

Table of Contents