308 CHAPTER 10 (Managed web hosting) USING FLASH TO DISPLAY

308 CHAPTER 10 USING FLASH TO DISPLAY XML If a title exists, the code creates a new element and adds an idattribute: var newDVD:XMLNode = oXML.createElement(“DVD”); newDVD.attributes.id = rootNode.childNodes.length + 1; It sets the value of the attribute to one more than the number of elements in the XML tree. The next code block creates a new element and uses appendChild() to add the text from the title_txt component: var newDVDTitle:XMLNode = oXML.createElement(“title”); newDVDTitle.appendChild(oXML.createTextNode(title_txt.text)); newDVD.appendChild(newDVDTitle); The code repeats this process for the<br /> <format> and <genre> nodes: if (format_txt.text.length > 0) { var newDVDFormat:XMLNode = oXML.createElement(“format”); newDVDFormat.appendChild(oXML.createTextNode(format_txt.text)); newDVD.appendChild(newDVDFormat); } if (genre_txt.text.length > 0) { var newDVDGenre:XMLNode = oXML.createElement(“genre”); newDVDGenre.appendChild(oXML.createTextNode(genre_txt.text)); newDVD.appendChild(newDVDGenre); } Finally, the code appends the <DVD> element to the root node, reloads the List component, and clears the values in the text field: rootNode.appendChild(newDVD); loadList(null); clearTextInputs(); Editing an existing node uses a different block of code that s easier to interpret. First, the code finds the child node index for the selected node so it can select the node again after the update: var selectedNodeIndex:Number = Number(selectedDVDNode.attributes.id)-1; Then it checks whether appropriate text has been entered into the TextField component and changes the nodeValue accordingly: if (title_txt.text.length > 0) { selectedDVDNode.childNodes[0].firstChild.nodeValue = title_txt.text; } if (format_txt.text.length > 0) { selectedDVDNode.childNodes[1].firstChild.nodeValue = format_txt.text; } if (genre_txt.text.length > 0) { selectedDVDNode.childNodes[2].firstChild.nodeValue = genre_txt.text; } <br />Searching for affordable and proven webhost to host and run your servlet applications? Go to <a href="http://linux.g5websitehosting.com">Linux Web Hosting</a> services and you will find it.</p> </div><!-- .entry-content --> <footer class="entry-meta2"> </footer><!-- #entry-meta --> </article><!-- #post-389 --> <article id="post-388" class="post-388 post type-post status-publish format-standard hentry category-tomcat"> <header class="entry-header"> <h1 class="entry-title"><a href="http://www.tomcatjavahosting.com/2007/11/30/web-design-course-chapter-10-using-flash-to-display-xml/" title="Permalink to Web design course – CHAPTER 10 USING FLASH TO DISPLAY XML" rel="bookmark">Web design course – CHAPTER 10 USING FLASH TO DISPLAY XML</a></h1> <div class="entry-meta">   <span class="author vcard" >By <a class="url fn n" href="http://www.tomcatjavahosting.com/author/admin-2/" title="View all posts by admin">admin</a> <span class="bl_sep">|</span></span> <span class="onDate"> <a href="http://www.tomcatjavahosting.com/2007/11/30/web-design-course-chapter-10-using-flash-to-display-xml/" title="9:11 am" rel="bookmark"><span class="entry-date">November 30, 2007</span> <span class="entry-time"> - 9:11 am</span></a> <span class="bl_sep">|</span> </span> <span class="bl_categ"> <a href="http://www.tomcatjavahosting.com/category/tomcat/" title="View all posts in Tomcat" rel="tag">Tomcat</a> </span> <div class="comments-link"> <span>Comments Off</span> </div> </div><!-- .entry-meta --> </header><!-- .entry-header --> <div class="entry-content"> <p>CHAPTER 10 USING FLASH TO DISPLAY XML 307 The doUpdate()function follows: function doUpdate():Void { if (booNew) { if (title_txt.text.length > 0) { var newDVD:XMLNode = oXML.createElement(“DVD”); newDVD.attributes.id = rootNode.childNodes.length + 1; var newDVDTitle:XMLNode = oXML.createElement(“title”); newDVDTitle.appendChild(oXML.createTextNode(title_txt.text)); newDVD.appendChild(newDVDTitle); if (format_txt.text.length > 0) { var newDVDFormat:XMLNode = oXML.createElement(“format”); newDVDFormat.appendChild(oXML.createTextNode(format_txt.text)); newDVD.appendChild(newDVDFormat); } if (genre_txt.text.length > 0) { var newDVDGenre:XMLNode = oXML.createElement(“genre”); newDVDGenre.appendChild(oXML.createTextNode(genre_txt.text)); newDVD.appendChild(newDVDGenre); } rootNode.appendChild(newDVD); loadList(null); clearTextInputs(); } } else { var selectedNodeIndex:Number = Number(selectedDVDNode.attributes.id)-1; if (title_txt.text.length > 0) { selectedDVDNode.childNodes[0].firstChild.nodeValue = title_txt.text; } if (format_txt.text.length > 0) { selectedDVDNode.childNodes[1].firstChild.nodeValue = format_txt.text; } if (genre_txt.text.length > 0) { selectedDVDNode.childNodes[2].firstChild.nodeValue = genre_txt.text; } loadList(selectedNodeIndex); } } You can divide the function into two areas the first section adds a new record, and the second edits an existing record. If you re adding a new record (booNew is true), the code tests whether the record has a title. The function won t proceed unless a title exists: if (title_txt.text.length > 0) { <br />If you are searching for cheap webhost for your web application, please visit <a href="http://tomcat.g5websitehosting.com">MySQL5 Web Hosting</a> services.</p> </div><!-- .entry-content --> <footer class="entry-meta2"> </footer><!-- #entry-meta --> </article><!-- #post-388 --> <article id="post-387" class="post-387 post type-post status-publish format-standard hentry category-tomcat"> <header class="entry-header"> <h1 class="entry-title"><a href="http://www.tomcatjavahosting.com/2007/11/29/306-chapter-10-using-flash-to-display-web-design-online/" title="Permalink to 306 CHAPTER 10 USING FLASH TO DISPLAY (Web design online)" rel="bookmark">306 CHAPTER 10 USING FLASH TO DISPLAY (Web design online)</a></h1> <div class="entry-meta">   <span class="author vcard" >By <a class="url fn n" href="http://www.tomcatjavahosting.com/author/admin-2/" title="View all posts by admin">admin</a> <span class="bl_sep">|</span></span> <span class="onDate"> <a href="http://www.tomcatjavahosting.com/2007/11/29/306-chapter-10-using-flash-to-display-web-design-online/" title="10:09 pm" rel="bookmark"><span class="entry-date">November 29, 2007</span> <span class="entry-time"> - 10:09 pm</span></a> <span class="bl_sep">|</span> </span> <span class="bl_categ"> <a href="http://www.tomcatjavahosting.com/category/tomcat/" title="View all posts in Tomcat" rel="tag">Tomcat</a> </span> <div class="comments-link"> <span>Comments Off</span> </div> </div><!-- .entry-meta --> </header><!-- .entry-header --> <div class="entry-content"> <p>306 CHAPTER 10 USING FLASH TO DISPLAY XML The processXML()function is almost identical to the previous example. When it calls the loadList() function, it passes null, signifying that a DVD has not yet been selected. The loadList() function works a little differently from the previous example. This time it displays a string representation of the complete XMLNode object in the List component. The new and changed lines appear in bold in the following code block: function loadList(theNodeIndex:Number):Void { dvd_list.removeAll(); var dvdNode:XMLNode; for (var i:Number=0; i < rootNode.childNodes.length; i++) { dvdNode = rootNode.childNodes[i]; dvd_list.addItem(dvdNode.toString()); } if (theNodeIndex != null) { dvd_list.selectedIndex = theNodeIndex; } } The toString() method displays the content of each element within the List component. The new example includes onRelease handlers for each of the three buttons: Clear, Update, and Delete. The Clear button clears the selection: clear_btn.onRelease = function():Void { dvd_list.selectedIndex = undefined; selectedDVDNode = null; booNew = true; clearTextInputs(); } The function starts by removing the selection from the dvd_list component: dvd_list.selectedIndex = undefined; It then clears the selectedDVDNode variable by setting the value to null. The function sets the booNew variable to true and then calls the clearTextInputs() function to remove the text from the interface. The clearTextInputs() function follows: function clearTextInputs():Void { title_txt.text = ""; format_txt.text = ""; genre_txt.text = ""; } Clicking the Update button calls the doUpdate() function. This function either adds a new record to the XML tree or updates the currently selected element, depending on the value of the booNew variable. <br />We highly recommend you visit <a href="http://coldfusion.smartwebsitehosting.net">web and email hosting</a> services if you need stable and cheap web hosting platform for your web applications.</p> </div><!-- .entry-content --> <footer class="entry-meta2"> </footer><!-- #entry-meta --> </article><!-- #post-387 --> <article id="post-386" class="post-386 post type-post status-publish format-standard hentry category-tomcat"> <header class="entry-header"> <h1 class="entry-title"><a href="http://www.tomcatjavahosting.com/2007/11/29/chapter-10-using-flash-to-display-xml-free-web-design/" title="Permalink to CHAPTER 10 USING FLASH TO DISPLAY XML (Free web design)" rel="bookmark">CHAPTER 10 USING FLASH TO DISPLAY XML (Free web design)</a></h1> <div class="entry-meta">   <span class="author vcard" >By <a class="url fn n" href="http://www.tomcatjavahosting.com/author/admin-2/" title="View all posts by admin">admin</a> <span class="bl_sep">|</span></span> <span class="onDate"> <a href="http://www.tomcatjavahosting.com/2007/11/29/chapter-10-using-flash-to-display-xml-free-web-design/" title="10:16 am" rel="bookmark"><span class="entry-date">November 29, 2007</span> <span class="entry-time"> - 10:16 am</span></a> <span class="bl_sep">|</span> </span> <span class="bl_categ"> <a href="http://www.tomcatjavahosting.com/category/tomcat/" title="View all posts in Tomcat" rel="tag">Tomcat</a> </span> <div class="comments-link"> <span>Comments Off</span> </div> </div><!-- .entry-meta --> </header><!-- .entry-header --> <div class="entry-content"> <p>CHAPTER 10 USING FLASH TO DISPLAY XML 305 Tip If you re not familiar with Flash, you can generate a web page that displays the SWF file by choosing File . Publish. Flash will create the web page in the same folder as the SWF file. In this example, you saw how to load an XML document into Flash and display it in UI components. You can also use Flash to update content and send it to a server-side file for processing. Updating XML Content in Flash As you saw earlier in this chapter, Flash can use methods such as createNode(), appendNode(), insertBefore(), and cloneNode() to manipulate an XML tree. The manipulation takes place within Flash, but if you need to update an external data source, you ll have to send the content to a server-side file for processing. I ll work through an example where I take user input and use it to update the dvd.xml document tree within Flash. You can find this example saved in the file dvd3.fla. Figure 10-5 shows the interface populated with the dvd.xml file. Figure 10-5. The interface of the dvd3.fla movie This interface allows you to view the details of a DVD, add a new DVD to the XML tree, and edit or remove an existing DVD. If you open Frame 1 of the actions layer with the F9 shortcut key, you ll see that it s a little more complicated than the previous example. To start with, there are now three timeline variables: var rootNode:XMLNode; var selectedDVDNode:XMLNode; var booNew:Boolean = true; The added third line creates a Boolean variable that determines whether to add a new node or to edit an existing node. <br />If you are in need for cheap and reliable webhost to host your website, we recommend <a href="http://mysql5.tomcatjavahosting.com">http web server</a> services.</p> </div><!-- .entry-content --> <footer class="entry-meta2"> </footer><!-- #entry-meta --> </article><!-- #post-386 --> <article id="post-385" class="post-385 post type-post status-publish format-standard hentry category-tomcat"> <header class="entry-header"> <h1 class="entry-title"><a href="http://www.tomcatjavahosting.com/2007/11/28/304-chapter-10-using-flash-to-display-web-hosting-servers/" title="Permalink to 304 CHAPTER 10 USING FLASH TO DISPLAY (Web hosting servers)" rel="bookmark">304 CHAPTER 10 USING FLASH TO DISPLAY (Web hosting servers)</a></h1> <div class="entry-meta">   <span class="author vcard" >By <a class="url fn n" href="http://www.tomcatjavahosting.com/author/admin-2/" title="View all posts by admin">admin</a> <span class="bl_sep">|</span></span> <span class="onDate"> <a href="http://www.tomcatjavahosting.com/2007/11/28/304-chapter-10-using-flash-to-display-web-hosting-servers/" title="11:10 pm" rel="bookmark"><span class="entry-date">November 28, 2007</span> <span class="entry-time"> - 11:10 pm</span></a> <span class="bl_sep">|</span> </span> <span class="bl_categ"> <a href="http://www.tomcatjavahosting.com/category/tomcat/" title="View all posts in Tomcat" rel="tag">Tomcat</a> </span> <div class="comments-link"> <span>Comments Off</span> </div> </div><!-- .entry-meta --> </header><!-- .entry-header --> <div class="entry-content"> <p>304 CHAPTER 10 USING FLASH TO DISPLAY XML The code starts by removing any existing items from the list. Then it declares a variable that will store the DVD id attribute value. The code loops through the childNodes array using a for loop. You ll notice that the construction is the same as within JavaScript: for (var i:Number=0; i < rootNode.childNodes.length; i++) { As in the previous chapters, the code uses the length property of the childNodes array to determine the end point for the loop. Within the loop, the code determines the id attribute value using this code: dvdID = rootNode.childNodes[i].attributes.id; This code finds the relevant childNodearray element and finds the id property within the attributes collection. Finally, the addItem() method adds the id attribute to the dvd_listList component: dvd_list.addItem(dvdID); The other block of code within the Actions panel responds to the user making a selection from the List component: var dvdListener:Object = new Object(); dvdListener.change = function(evtObj:Object):Void { var nodeIndex:Number = evtObj.target.selectedIndex; selectedDVDNode = rootNode.childNodes[nodeIndex]; title_txt.text = selectedDVDNode.childNodes[0].firstChild.nodeValue; format_txt.text = selectedDVDNode.childNodes[1].firstChild.nodeValue; genre_txt.text = selectedDVDNode.childNodes[2].firstChild.nodeValue; } dvd_list.addEventListener("change", dvdListener); The code defines an event listener object called dvdListener and adds it to the dvd_list component, listening for the change event. When the object detects the event, it determines which item the user selected and stores it within the nodeIndex variable: var nodeIndex:Number = evtObj.target.selectedIndex; It then uses that value to set an XMLNode object to reference the appropriate element in the XML object: selectedDVDNode = rootNode.childNodes[nodeIndex]; Finally, the function sets the text property of each TextInput component to the value from the appropriate element in the XML object. For example, the title comes from the first child node (childNodes[0]) of the <dvd>element. You can find the text by using the firstChild property of this element and determining the nodeValue: title_txt.text = selectedDVDNode.childNodes[0].firstChild.nodeValue; Testing the Flash document shows something similar to Figure 10-2. You should be able to select each DVD from the Listcomponent and see the title, format, and genre of each. <br />If you are looking for cheap and quality webhost to host and run your website check <a href="http://php5.g5websitehosting.com">Jboss Web Hosting</a> services.</p> </div><!-- .entry-content --> <footer class="entry-meta2"> </footer><!-- #entry-meta --> </article><!-- #post-385 --> <article id="post-384" class="post-384 post type-post status-publish format-standard hentry category-tomcat"> <header class="entry-header"> <h1 class="entry-title"><a href="http://www.tomcatjavahosting.com/2007/11/28/free-web-host-chapter-10-using-flash-to-display-xml/" title="Permalink to Free web host – CHAPTER 10 USING FLASH TO DISPLAY XML" rel="bookmark">Free web host – CHAPTER 10 USING FLASH TO DISPLAY XML</a></h1> <div class="entry-meta">   <span class="author vcard" >By <a class="url fn n" href="http://www.tomcatjavahosting.com/author/admin-2/" title="View all posts by admin">admin</a> <span class="bl_sep">|</span></span> <span class="onDate"> <a href="http://www.tomcatjavahosting.com/2007/11/28/free-web-host-chapter-10-using-flash-to-display-xml/" title="11:21 am" rel="bookmark"><span class="entry-date">November 28, 2007</span> <span class="entry-time"> - 11:21 am</span></a> <span class="bl_sep">|</span> </span> <span class="bl_categ"> <a href="http://www.tomcatjavahosting.com/category/tomcat/" title="View all posts in Tomcat" rel="tag">Tomcat</a> </span> <div class="comments-link"> <span>Comments Off</span> </div> </div><!-- .entry-meta --> </header><!-- .entry-header --> <div class="entry-content"> <p>CHAPTER 10 USING FLASH TO DISPLAY XML 303 You can press the F9 shortcut key to see the actions added to this frame in the Actions panel. All of the ActionScript required to run this simple application appears on Frame 1 of this layer. I ll work through the code. The code starts by declaring timeline variables. These are similar to variables with global scope in a JavaScript code block: var rootNode:XMLNode; var selectedDVDNode:XMLNode; The rootNode variable stores a reference to the document element. In the dvd.xml file, that s the <library> element. The selectedDVDNodevariable stores a reference to the DVD chosen by the user. The next code block loads the XML document and sets the onLoad event handler: var oXML:XML = new XML(); oXML.ignoreWhite = true; oXML.onLoad = processXML; oXML.load(“dvd.xml”); When the dvd.xml document loads into Flash, it calls the processXML function. The function appears at the bottom of the Actions panel: function processXML(success:Boolean):Void{ if (success){ if (this.status == 0) { rootNode = this.firstChild; loadList(); } } } This function starts by testing that the XML document loaded successfully. It then checks the value of the status property to make sure that there are no errors. The remaining lines set the value of the rootNode variable to the first child of the loaded XML object, and call the loadList function: rootNode = this.firstChild; loadList(); Setting the rootNode variable is useful because it allows an application to access content from the XML document, without the XML declaration, from anywhere within the Flash movie. The loadList() function loads the content into the Listcomponent: function loadList():Void { dvd_list.removeAll(); var dvdID:Number; for (var i:Number=0; i < rootNode.childNodes.length; i++) { dvdID = rootNode.childNodes[i].attributes.id; dvd_list.addItem(dvdID); } } <br />If you are in need for cheap and reliable webhost to host your website, we recommend <a href="http://mysql5.tomcatjavahosting.com">http web server</a> services.</p> </div><!-- .entry-content --> <footer class="entry-meta2"> </footer><!-- #entry-meta --> </article><!-- #post-384 --> <article id="post-383" class="post-383 post type-post status-publish format-standard hentry category-tomcat"> <header class="entry-header"> <h1 class="entry-title"><a href="http://www.tomcatjavahosting.com/2007/11/27/302-chapter-10-shared-web-hosting-using-flash-to-display/" title="Permalink to 302 CHAPTER 10 (Shared web hosting) USING FLASH TO DISPLAY" rel="bookmark">302 CHAPTER 10 (Shared web hosting) USING FLASH TO DISPLAY</a></h1> <div class="entry-meta">   <span class="author vcard" >By <a class="url fn n" href="http://www.tomcatjavahosting.com/author/admin-2/" title="View all posts by admin">admin</a> <span class="bl_sep">|</span></span> <span class="onDate"> <a href="http://www.tomcatjavahosting.com/2007/11/27/302-chapter-10-shared-web-hosting-using-flash-to-display/" title="11:29 pm" rel="bookmark"><span class="entry-date">November 27, 2007</span> <span class="entry-time"> - 11:29 pm</span></a> <span class="bl_sep">|</span> </span> <span class="bl_categ"> <a href="http://www.tomcatjavahosting.com/category/tomcat/" title="View all posts in Tomcat" rel="tag">Tomcat</a> </span> <div class="comments-link"> <span>Comments Off</span> </div> </div><!-- .entry-meta --> </header><!-- .entry-header --> <div class="entry-content"> <p>302 CHAPTER 10 USING FLASH TO DISPLAY XML Figure 10-2. Displaying XML content in UI components I ll walk through this example so you can see how to traverse the document tree. The example will also show you how to work with the UI components in Flash. Open the dvd2.fla file in Flash 8, and you ll see a number of UI components on the Stage. If you re not familiar with Flash, clicking each component displays its name in the Properties panel at the bottom of the screen. Figure 10-3 shows the Properties panel with the List component selected. I can refer to a component using this name. Figure 10-3. The Properties panel showing a component instance name You ll also see two layers in the timeline in the top left-hand corner of the screen. Select Frame 1 of the actionslayer, as shown in Figure 10-4. Figure 10-4. Selecting Frame 1 of the actions layer <br />Please visit our <a href="http://php5.smartwebsitehosting.net">professional web hosting</a> services to find out about cheap and reliable webhost service that will surely answer all your demands.</p> </div><!-- .entry-content --> <footer class="entry-meta2"> </footer><!-- #entry-meta --> </article><!-- #post-383 --> <article id="post-382" class="post-382 post type-post status-publish format-standard hentry category-tomcat"> <header class="entry-header"> <h1 class="entry-title"><a href="http://www.tomcatjavahosting.com/2007/11/27/chapter-10-using-flash-to-display-xml-best-web-site/" title="Permalink to CHAPTER 10 USING FLASH TO DISPLAY XML (Best web site)" rel="bookmark">CHAPTER 10 USING FLASH TO DISPLAY XML (Best web site)</a></h1> <div class="entry-meta">   <span class="author vcard" >By <a class="url fn n" href="http://www.tomcatjavahosting.com/author/admin-2/" title="View all posts by admin">admin</a> <span class="bl_sep">|</span></span> <span class="onDate"> <a href="http://www.tomcatjavahosting.com/2007/11/27/chapter-10-using-flash-to-display-xml-best-web-site/" title="11:29 am" rel="bookmark"><span class="entry-date">November 27, 2007</span> <span class="entry-time"> - 11:29 am</span></a> <span class="bl_sep">|</span> </span> <span class="bl_categ"> <a href="http://www.tomcatjavahosting.com/category/tomcat/" title="View all posts in Tomcat" rel="tag">Tomcat</a> </span> <div class="comments-link"> <span>Comments Off</span> </div> </div><!-- .entry-meta --> </header><!-- .entry-header --> <div class="entry-content"> <p>CHAPTER 10 USING FLASH TO DISPLAY XML 301 appendChild(newChild:XMLNode) The appendChild()method adds a new child after the last child node of the current XMLNode object. You can use this method to append a node that you ve just created: oNewNode = oXML.createElement(“dvd”); oXML.childNodes[0].appendChild(oNewNode); You can also use the method to move an existing node to a new location. cloneNode(deep:Boolean) The cloneNode()method clones an existing XMLNodeobject. It copies all attributes within the node. Set the deep parameter to true to clone all child nodes recursively: oXML.oXMLNode.cloneNode(true) The method returns the cloned node without a parent. You ll need to use appendChild() or insertBefore() to locate it within the document tree. insertBefore(newChild:XMLNode, insertPoint:XMLNode) This method inserts a new XMLNode object before an existing XMLNode object: var oOldNode:XMLNode = oXML.firstChild.childNode[1]; var oNewNode:XMLNode = oXML.createElement(“dvd”); oXML.insertBefore(oNewNode, oOldNode); If insertPoint is not a child of the XMLNode object, the insert will fail. removeNode() The removeChild()method removes the specified XMLNode. It returns nothing: var nodeToRemove:XMLNode = oXML.firstChild.childNodes[2]; nodeToRemove.removeNode(); Loading and Displaying XML Content in Flash In the previous section, I covered the methods and properties that are available to you when working with XML content in Flash. These will make much more sense if I work through an example. The example file dvd2.fla shows how to load the dvd.xml file into Flash and display the details of a selected DVD in UI components. Figure 10-2 shows this movie with a selected DVD. <br />You need excellent and relaible webhost company to host your web applications? Then pay a visit to <a href="http://www.g5websitehosting.com">Inexpensive Web Hosting</a> services.</p> </div><!-- .entry-content --> <footer class="entry-meta2"> </footer><!-- #entry-meta --> </article><!-- #post-382 --> <article id="post-381" class="post-381 post type-post status-publish format-standard hentry category-tomcat"> <header class="entry-header"> <h1 class="entry-title"><a href="http://www.tomcatjavahosting.com/2007/11/27/300-chapter-10-using-flash-to-display-top-ten-web-hosting/" title="Permalink to 300 CHAPTER 10 USING FLASH TO DISPLAY (Top ten web hosting)" rel="bookmark">300 CHAPTER 10 USING FLASH TO DISPLAY (Top ten web hosting)</a></h1> <div class="entry-meta">   <span class="author vcard" >By <a class="url fn n" href="http://www.tomcatjavahosting.com/author/admin-2/" title="View all posts by admin">admin</a> <span class="bl_sep">|</span></span> <span class="onDate"> <a href="http://www.tomcatjavahosting.com/2007/11/27/300-chapter-10-using-flash-to-display-top-ten-web-hosting/" title="12:08 am" rel="bookmark"><span class="entry-date">November 27, 2007</span> <span class="entry-time"> - 12:08 am</span></a> <span class="bl_sep">|</span> </span> <span class="bl_categ"> <a href="http://www.tomcatjavahosting.com/category/tomcat/" title="View all posts in Tomcat" rel="tag">Tomcat</a> </span> <div class="comments-link"> <span>Comments Off</span> </div> </div><!-- .entry-meta --> </header><!-- .entry-header --> <div class="entry-content"> <p>300 CHAPTER 10 USING FLASH TO DISPLAY XML firstChild and lastChild The firstChild and lastChildproperties return the first and last XMLNode objects in the XMLNode s list of child nodes: oXMLNode.firstChild oXMLNode.lastChild If there are no children, the lastChildproperty returns null. Note that text nodes are always the first child of their containing element. previousSibling and nextSibling These properties return the previous and next XMLNode objects that share the same parent as the current XMLNode object: oXMLNode.previousSibling oXMLNode.nextSibling nodeType Unlike the XML DOM property of the same name, this property returns a value of either 1 (element node) or 3 (text node) for the specified XMLNode: oXMLNode.nodeType Flash doesn t support the other numeric node type indicators from the recommendation. nodeName The nodeName property returns the name of the current XMLNode object: oXMLNode.nodeName Text nodes don t have a nodeName property. XMLNodes with a nodeType of 3 i.e., text nodes will return null. nodeValue The nodeValue property returns the content of the specified text node: oXMLNode.firstChild.nodeValue The preceding line finds the text within the oXMLNode element. Note that the text node is the firstChild of the XMLNode object. The property returns null for an element node (nodeType = 1). hasChildNodes() The hasChildNodes()method returns a Boolean value that indicates whether an XMLNode object has child elements: oXMLNode.hasChildNodes() <br />Please visit <a href="http://domain.g5websitehosting.com">Domain Name Hosting</a> services for high quality webhost to host and run your jsp applications.</p> </div><!-- .entry-content --> <footer class="entry-meta2"> </footer><!-- #entry-meta --> </article><!-- #post-381 --> <article id="post-380" class="post-380 post type-post status-publish format-standard hentry category-tomcat"> <header class="entry-header"> <h1 class="entry-title"><a href="http://www.tomcatjavahosting.com/2007/11/26/chapter-10-using-flash-to-display-xml-free-web-servers/" title="Permalink to CHAPTER 10 USING FLASH TO DISPLAY XML (Free web servers)" rel="bookmark">CHAPTER 10 USING FLASH TO DISPLAY XML (Free web servers)</a></h1> <div class="entry-meta">   <span class="author vcard" >By <a class="url fn n" href="http://www.tomcatjavahosting.com/author/admin-2/" title="View all posts by admin">admin</a> <span class="bl_sep">|</span></span> <span class="onDate"> <a href="http://www.tomcatjavahosting.com/2007/11/26/chapter-10-using-flash-to-display-xml-free-web-servers/" title="1:08 pm" rel="bookmark"><span class="entry-date">November 26, 2007</span> <span class="entry-time"> - 1:08 pm</span></a> <span class="bl_sep">|</span> </span> <span class="bl_categ"> <a href="http://www.tomcatjavahosting.com/category/tomcat/" title="View all posts in Tomcat" rel="tag">Tomcat</a> </span> <div class="comments-link"> <span>Comments Off</span> </div> </div><!-- .entry-meta --> </header><!-- .entry-header --> <div class="entry-content"> <p>CHAPTER 10 USING FLASH TO DISPLAY XML 299 Unlike the XML DOM, ActionScript doesn t include the replaceChild() method. Let s look at each of these methods and properties so you can understand them in more detail. attributes The attributes property returns an object containing all of the attributes of the specified XMLNode object: oXMLNode.attributes You can loop through all attributes within the XMLNode using this code: for (var theAtt:String in oXMLNode.attributes) { ..//process attributes } parentNode The parentNode property returns the XMLNode that is the parent of the current node: oXMLNode.parentNode Remember that attributes don t have a parent node, as they are not the children of their containing element. If the node doesn t have a parent, it returns null. childNodes The childNodes property returns an array of child XMLNode objects: oXMLNode.childNodes You can refer to a specific child node by using its position within the collection: oXMLNode.childNodes[0] The previous line refers to the first child node of the oXMLNode element. You can find out how many child nodes exist within an element by using the length property: oXMLNode.childNodes.length This allows you to loop through the collection: for (var i:Number=0; i < oXMLNode.childNodes.length; i++) { //do something } As text nodes don t have child nodes, this property will return undefined. <br />Please visit <a href="http://domain.g5websitehosting.com">Domain Name Hosting</a> services for high quality webhost to host and run your jsp applications.</p> </div><!-- .entry-content --> <footer class="entry-meta2"> </footer><!-- #entry-meta --> </article><!-- #post-380 --> <nav class='pagination'><span class='current'>1</span><a href='http://www.tomcatjavahosting.com/2007/11/page/2/' class='inactive' >2</a><a href='http://www.tomcatjavahosting.com/2007/11/page/3/' class='inactive' >3</a><a href='http://www.tomcatjavahosting.com/2007/11/page/2/'>›</a><a href='http://www.tomcatjavahosting.com/2007/11/page/7/'>»</a></nav> </div><!-- #content --> <div id="primary" class="widget-area" role="complementary"> <ul class="xoxo"> <li id="search-2" class="widget-container widget_search"> <form method="get" id="searchform" action="http://www.tomcatjavahosting.com//"> <input type="text" value="Search" name="s" id="s" onblur="if (this.value == '') {this.value = 'Search';}" onfocus="if (this.value == 'Search') {this.value = '';}" /> <input type="submit" id="searchsubmit" value="OK" /> </form></li> <li id="recent-posts-2" class="widget-container widget_recent_entries"> <h3 class="widget-title">Recent Posts</h3> <ul> <li> <a href="http://www.tomcatjavahosting.com/2012/08/17/j-rn-zaefferer-is-a-professional-software-developer-from/">J rn Zaefferer is a professional software developer from</a> </li> <li> <a href="http://www.tomcatjavahosting.com/2012/08/16/about-the-reviewers-marc-grabanski-got-involved-early/">About the Reviewers Marc Grabanski got involved early</a> </li> <li> <a href="http://www.tomcatjavahosting.com/2012/08/15/about-the-author-dan-wellman-lives-with-his/">About the Author Dan Wellman lives with his</a> </li> <li> <a href="http://www.tomcatjavahosting.com/2012/08/14/credits-author-dan-wellman-reviewers-marc-grabanski-akash/">Credits Author Dan Wellman Reviewers Marc Grabanski Akash</a> </li> <li> <a href="http://www.tomcatjavahosting.com/2012/08/13/jquery-ui-1-7-the-user-interface-library-for-2/">jQuery UI 1.7 The User Interface Library for</a> </li> </ul> </li><li id="archives-2" class="widget-container widget_archive"><h3 class="widget-title">Archives</h3> <ul> <li><a href='http://www.tomcatjavahosting.com/2012/08/'>August 2012</a></li> <li><a href='http://www.tomcatjavahosting.com/2008/01/'>January 2008</a></li> <li><a href='http://www.tomcatjavahosting.com/2007/12/'>December 2007</a></li> <li><a href='http://www.tomcatjavahosting.com/2007/11/'>November 2007</a></li> <li><a href='http://www.tomcatjavahosting.com/2007/10/'>October 2007</a></li> <li><a href='http://www.tomcatjavahosting.com/2007/09/'>September 2007</a></li> <li><a href='http://www.tomcatjavahosting.com/2007/08/'>August 2007</a></li> <li><a href='http://www.tomcatjavahosting.com/2007/07/'>July 2007</a></li> <li><a href='http://www.tomcatjavahosting.com/2007/05/'>May 2007</a></li> <li><a href='http://www.tomcatjavahosting.com/2007/04/'>April 2007</a></li> </ul> </li><li id="linkcat-2" class="widget-container widget_links"><h3 class="widget-title">Blogroll</h3> <ul class='xoxo blogroll'> <li><a href="http://www.astrawebhosting.net/blog/">Adult Web Hosting</a></li> <li><a href="http://apache.tomcatjavahosting.com">Apache Web Hosting</a></li> <li><a href="http://jsp.tomcatjavahosting.com">Christian Web Host</a></li> <li><a href="http://coldfusion.tomcatjavahosting.com">Coldfusion Web Hosting</a></li> <li><a href="http://www.visionwebhosting.net/blog/">Database Web Hosting</a></li> <li><a href="http://www.virtualwebstudio.com/blog/">Dedicated Web Hosting</a></li> <li><a href="http://domain.g5websitehosting.com">Domain Name Hosting</a></li> <li><a href="http://jboss.tomcatjavahosting.com">Ecommerce Web Host</a></li> <li><a href="http://www.gamahosting.net/blog/">Frontpage Web Hosting</a></li> <li><a href="http://domain.smartwebsitehosting.net">Ftp Web Hosting</a></li> <li><a href="http://mysql5.tomcatjavahosting.com">Http Web Server</a></li> <li><a href="http://www.g5websitehosting.com">Inexpensive Web Hosting</a></li> <li><a href="http://j2ee.tomcatjavahosting.com">J2ee Web Hosting</a></li> <li><a href="http://www.visionwebhosting.net">Java hosting</a></li> <li><a href="http://tomcat.smartwebsitehosting.net">Java Server Pages</a></li> <li><a href="http://www.tomcatjavahosting.com">Java Web Hosting</a></li> <li><a href="http://www.smartwebsitehosting.net">Java Web Server</a></li> <li><a href="http://php5.g5websitehosting.com">Jboss Hosting</a></li> <li><a href="http://linux.g5websitehosting.com">Linux Web Hosting</a></li> <li><a href="http://mysql.g5websitehosting.com">MySQL Web Server</a></li> <li><a href="http://tomcat.g5websitehosting.com">MySQL5 Web Hosting</a></li> <li><a href="http://www.worldmythology.ws">Mythology</a></li> <li><a href="http://j2ee.g5websitehosting.com">Personal Web Hosting</a></li> <li><a href="http://www.omnicus.net/">Personal Web Server Hosting</a></li> <li><a href="http://php5.tomcatjavahosting.com">PHP5 Hosting</a></li> <li><a href="http://www.cheap-web-hosting-reviews.net">PHP5 Web Hosting</a></li> <li><a href="http://php5.smartwebsitehosting.net">Professional Web Hosting</a></li> <li><a href="http://mysql5.smartwebsitehosting.net">Servlet Web Hosting</a></li> <li><a href="http://j2ee.smartwebsitehosting.net">Shared Web Hosting</a></li> <li><a href="http://domain.tomcatjavahosting.com">Tomcat Web Hosting</a></li> <li><a href="http://jboss.smartwebsitehosting.net">Virtual Web Hosting</a></li> <li><a href="http://www.superbvpn.com">Vpn</a></li> <li><a href="http://www.supervpn.net">Vpn services</a></li> <li><a href="http://www.supervpshosting.net">Vps hosting</a></li> <li><a href="http://coldfusion.smartwebsitehosting.net">Web And Email Hosting</a></li> <li><a href="http://mysql5.g5websitehosting.com">Web Design Programs</a></li> <li><a href="http://www.webhostingjava.net/">Web Hosting Mysql5</a></li> <li><a href="http://www.webhostingphp.net/">Web Hosting Plans</a></li> <li><a href="http://www.actionswebhosting.com/blog/">Web Hosting Services</a></li> <li><a href="http://www.sandzak.com/blog/">Web Server Hosting</a></li> <li><a href="http://www.alphawebhosting.net/blog/">Web Site Optimization Hosting</a></li> </ul> </li> </ul> <ul class="xoxo"> </ul> </div><!-- #primary .widget-area --> <!-- 1c --> </section><!-- #primary --> <div style="clear:both;"></div> </div> <!-- #forbottom --> </div><!-- #main --> <footer id="footer" role="contentinfo"> <div id="colophon"> </div><!-- #colophon --> <div id="footer2"> <div id="site-info" > <a href="http://www.tomcatjavahosting.com/" title="Java Web Hosting, Subdomain, Vps Hosting, Cpanel, Programming Blog" rel="home">Java Web Hosting, Subdomain, Vps Hosting, Cpanel, Programming Blog</a> | <b title="1.9.7">Mantra</b> Theme by <a href="http://www.riotreactions.com" title="Visit author homepage">Cryout Creations</a> | Powered by <a href="http://wordpress.org/" title="Semantic Personal Publishing Platform"> WordPress. </a> </div><!-- #site-info --> </div><!-- #footer2 --> </footer><!-- #footer --> </div><!-- #wrapper --> </body> </html>