XML
  Home arrow XML arrow Page 5 - MSXML Tutorial
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

MSXML Tutorial
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 25
    2006-03-16

    Table of Contents:
  • MSXML Tutorial
  • Getting Down and Dirty with MSXML
  • Loading a Document
  • Adding a New Element
  • The LoadNewNode() Function

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    MSXML Tutorial - The LoadNewNode() Function


    (Page 5 of 5 )

    The InsertFirst(), InsertLast(), InsertBefore(), and InsertAfter() functions must retrieve information about the new CD from the text area. This is done by calling the LoadNewNode() method. The LoadNewNode() method loads information about the new CD from the text area into the DOM parser and then returns a reference to the root node of the information about the new CD to one of the four functions that called it. Here’s the LoadNewNode() method:

    function LoadNewNode()
    {
       var xmlNewNode = document.all("newnode").value;
       var objNewNode = new ActiveXObject("MSXML2.DOMDocument.4.0"); 
       objNewNode.async = false; 
       objNewNode.loadXML(xmlNewNode);
       if (objNewNode.parseError.errorCode != 0)
       {
         
    alert("Error loading new node: " + objNewNode.parseError.reason);
    return null;
       }
      
    else
       {
          return objNewNode.documentElement;
       }
    }

    The first line retrieves text from the text area on the HTML form.

    The second line creates a new DOMDocument object that contains information about the new CD.

    The third line sets the value for the async property to false so that the entire document loads before returning control to the calling point.

    The fourth line calls the loadXML() method of the DOMDocument object. The loadXML() method works similarly to the load() method called within the LoadDocument() function except the loadXML() method is used when the argument is a string. In this case, you’re passing the actual XML document as an argument instead of passing a URL that points to the document.

    The fifth line checks if an error occurred when loading information about the new CD. If there is an error, then an error message is displayed. If there isn’t an error, then the value of the documentElement of the DOMDocument is returned to the statement that called the LoadNewNode() method. The documentElement is the root element of the document, which is a reference to the <cd> element and all its child elements.

    Please check back next week for the second part of this article.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This article is an excerpt from the book "XML DeMSYTified," published by...
       · could do with a simple top view or bullet points showing structure to precede the...
     

    Buy this book now. This article is excerpted from chapter 10 of XML DeMYSTified, written by Jim Keogh and Ken Davidson (McGraw-Hill/Osborne, 2005; ISBN: 0072262109). Check it out today at your favorite bookstore. Buy this book now.

    XML ARTICLES

    - More on Triggers and Styles and Control Temp...
    - Looking at Triggers with Styles and Control ...
    - A Closer Look at Styles and Control Templates
    - Styles and Control Templates
    - Properties and More in XAML
    - Elements and Attributes in XAML
    - XAML in a Nutshell
    - Importing XML Files into Access 2007
    - Using MSXML3.0 with VB 6.0
    - MSXML, concluded
    - MSXML, continued
    - MSXML Tutorial
    - Generating XML Schema Dynamically Using VB.N...
    - XSL Transformations using ASP.NET
    - Applying XSLT to XML Using ASP.NET





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT