
CHAPTER 9: Integrating XML into JavaScript XML Object Reference 254
Global functions
These functions are available in the JavaScript global namespace.
xpath()
xmlObj.xpath (expression[, variables]);
expression
A String containing an XPath expression.
N
OTE: In this context, include the actual top level element. For example, an
expression for the example XML must start with “/bookstore”. This is unlike
JavaScript property access, where the top level element is implied.
variables
Optional. A JavaScript object containing variable definitions. The properties are used
to look up XPath variables contained in the expression. For example, if the
expression contains the variable
$abc, the value is in the object’s abc property.
Evaluates an XPath expression in accordance with the W3C XPath recommendation, using this XML
object as the context node. The context position and size are set to 1, and all variables are initially
unbound. If this XML object is a list, evaluates all contained XML element nodes (not comments or
other node types) and return the results in a list in the order of execution.
If the XPath expression does not evaluate to a node list, throws a JavaScript exception.
Returns an XML object
, the result of evaluation.
isXMLName()
isXMLName (String name)
name
A string.
Reports whether a string contains a name that conforms to valid XML syntax.
N
OTE: This implementation uses the same rules as for a JavaScript name, except for the '$' character,
which is disallowed, and the '-' character, which as added. It does not follow the W3C definition of an
XML name, which adds more Unicode characters to the valid set of characters.
Returns true if the name is a valid XML name, false otherwise.
setDefaultXMLNamespace()
setDefaultXMLNamespace (Namespace ns)
ns
A Namespace object. Any prefix is ignored.
Sets the default namespace for XML objects. You can also set the default namespace using this
syntax:
default xml namespace = Namespace object
default xml namespace = URL_string
Returns undefined.
Kommentare zu diesen Handbüchern