short discussion on the new appendChild() method
Brought to you by:
bs_php,
nigelswinson
From: <php...@li...> - 2001-10-22 03:34:22
|
I would like to quickly explain why I chose to implement this function as I did....the appendChild funtion can take a "document-fragment" according to the w3c recommendation. Now, there is a very interesting thing about a document fragement. The way I set it up, you can pass in the following xml string to be inserted... <book id="2"> <title>First Book</title> </book> <book id="4"> <title>Second Book</title> </book> I am going to allow that, but technically that is not a document fragment, that is what is referred to as a node-set...A document fragment is a partial xml document, where there is a single "root" node and children, etc. of that node...However, when the document fragment is inserted into xmltree, ONLY the children of that "root" node are inserted, so the "root" node is really just garbage...Daniel Viellard came up with a convention that I used in my function...he takes what the user types, like above, wraps it inside of <fake> </fake> tags, to create a document fragment...since the "fake" gets tossed anyway, it is okay to just add that to the user's xmlString in order to work with it like a document fragment. So, the one thing I need to go back and add to the appendChild is to check for </> tags, because if they are not there, it should create an empty tag with that name... Dan _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |