The Official Blog of Patcoola

Im just a dude watching over my parents,
and trying to make cartoons and video games from home.

XML API [JavaScript]

, By Patcoola

Script Title: XML API
Programming Language: JavaScript
Date Created: 2020-03-31

Purpose: An easy to use interface to navigate XML documents.

Description: A XML application programming interface to load and navigate XML documents. Provides many useful functions.

Advertisement


Methods

xml.loader ( {

url: String
method: String [GET | POST], default GET
async: Boolean, default true
exec: Function

} );

Functions

xml.node(element).hasAttribute(string);

// Checks if element has an attribute, returns a Boolean

xml.node(element).getAttribute(string);

// Returns the value of an attribute as a string

xml.node(element).hasByTagName(string);

// Checks if a parent node contents an element with a given tag name, returns a Boolean

xml.node(element).getByTagName(string);

// Returns a DOM of elements with a given tag name within an element

xml.doc(string).getID(string);

// Returns an element with a given ID from an XML document

xml.read(xml);

// Manually select and process an XML document into the API

xml.getList();

// Lists the XML documents in the API, returns a one dimensional array

xml.getRoots(string);

// Lists the parent elements in an XML document, returns a two dimensional array [ Element Name, node ]

xml.count();

// Returns the number of XML documents in the API

xml.remove(string);

// Removes an XML document from the API

xml.getValue(element);

// Returns the value of an element, value data type is set by the data-type attribute or by a definitions table

xml.scan(element);

// Scans an element and returns a two dimensional array [ Element Name, node ]

xml.keys(element);

// Scans an elements and returns the nodes as objects { name: node }

xml.stringToXML(string);

// Converts an XML string into an XML document, returns an XML document

Example Usage

xml.loader ( {

url: “cuesheet.xml”,

exec: helloworld

} );

function helloworld () {

alert ( “Hello world the document was loaded!” );

}

 

Advertisement


 

Post Meta

Share Post

 

Comments: Write Comment

Be the first to write a comment.


Leave a Comment


All comments are reviewed before publishing. Comments must be related to the page topic, must not be spam, and must comply with the criminal code of Canada.

 

Matched Content