02.06.2013 Views

XML Demystified

XML Demystified

XML Demystified

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

162<br />

<strong>XML</strong> Demystifi ed<br />

in the browser. Each function references the text area value when inserting the new<br />

CD into the <strong>XML</strong> document.<br />

<br />

<br />

Insert First:<br />

Insert Last:<br />

Insert Before UPC:<br />

<br />

Insert After UPC:<br />

<br />

<br />

<br />

<br />

Phish<br />

Live Phish, Vol. 15<br />

26.99<br />

ELEKTRA/WEA<br />

2002-10-29<br />

<br />

<br />

<br />

<br />

The LoadNewNode() Function<br />

The InsertFirst(), InsertLast(), InsertBefore(), and InsertAfter() functions must<br />

retrieve information about the new CD from the text area. This is done by calling<br />

the LoadNewNode() method. The LoadNewNode() method loads information about<br />

the new CD from the text area into the DOM parser and then returns a reference to<br />

the root node of the information about the new CD to one of the four functions that<br />

called it. Here’s the LoadNewNode() method:<br />

function LoadNewNode()<br />

{<br />

var xmlNewNode = document.all("newnode").value;<br />

var objNewNode = new ActiveXObject("MS<strong>XML</strong>2.DOMDocument.4.0");<br />

objNewNode.async = false;<br />

objNewNode.load<strong>XML</strong>(xmlNewNode);<br />

if (objNewNode.parseError.errorCode != 0)<br />

{<br />

alert("Error loading new node: " + objNewNode.parseError.reason);<br />

return null;<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!