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.

172<br />

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

before that. The API does not have an insertAfter() method so this is another way to<br />

accomplish the same thing. Suppose you were inserting after the last node in the<br />

list. i+1 would not reference a valid node because it’s beyond the boundary of the<br />

list. The second argument would evaluate to null. When the method sees null as the<br />

second argument, it puts the new node last in the list. It’s equivalent to calling<br />

appendNode(). The <strong>XML</strong> document is then displayed before the function returns to<br />

the statement that called the InsertAfter() function.<br />

If they don’t match, then the function returns without changing the <strong>XML</strong><br />

document.<br />

Here’s the <strong>XML</strong> document after the new CD is inserted:<br />

<br />

<br />

<br />

<br />

U2<br />

How to Dismantle an Atomic Bomb<br />

13.98<br />

Interscope Records<br />

2004-11-23<br />

<br />

<br />

Led Zeppelin<br />

Physical Graffiti<br />

22.99<br />

Atlantic<br />

1994-08-16<br />

<br />

<br />

Rush<br />

Rush in Rio<br />

13.98<br />

Atlantic<br />

2003-10-21<br />

<br />

<br />

Phish<br />

Live Phish, Vol. 15<br />

26.99<br />

ELEKTRA/WEA<br />

2002-10-29<br />

<br />

<br />

Billy Joel

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

Saved successfully!

Ooh no, something went wrong!