XML
  Home arrow XML arrow Page 4 - 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 
Moblin 
JMSL Numerical Library 
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 - Adding a New Element


    (Page 4 of 5 )

    The XML document contains information about CDs. Each CD has a upc attribute and five child elements. Add the following CD to the catalog:

    <cd upc="75596280822"> 
       <artist>Phish</artist>
       <title>Live Phish, Vol. 15</title>  
       <price>26.99</price> 
       <label>ELEKTRA/WEA</label>
       <date>2002-10-29</date>
    </cd>

    You’ll need to use four different functions to determine where to place the new CD within the XML document. These functions are

    • InsertFirst()  Put the new entry at the beginning of the list
    • InsertLast()  Put the new entry at the end of the list
    • InsertBefore()  Put the new entry before the CD with the given upc attribute
    • InsertAfter()  Put the new entry after the CD with the given upc attribute

    Each function is called by an option on the HTML form. Options appear in the first column of the table. The user of the application decides the position of the new CD within the XML document by selecting the appropriate option.

    The first two options place the new CD at the beginning or at the end of the XML document, respectively. The last two options require the user to specify a UPC. The UPC is the identifier for a CD that’s already in the XML document. The function then places the new CD either before or after the CD that the user specifies.

    The second column contains a text area containing information about the new CD. We’ve provided a default value when the page loads, but you can change this in the browser. Each function references the text area value when inserting the new CD into the XML document.

    <tr valign="top">
    <td nowrap>
    <a href="#" onclick="InsertFirst();
      
    return false;">Insert First:</a><br>
    <a href="#" onclick="InsertLast();
       return false;">Insert Last:</a><br>
    <a href="#" onclick="InsertBefore(document.all('upcBefore').value);
       return false;">Insert Before UPC:</a> 
       <input type="text" id="upcBefore"
          value="75678367229" size="15"><br>
    <a href="#" onclick="InsertAfter(document.all('upcAfter').value);
       return false;">Insert After UPC:</a> 
       <input type="text" id="upcAfter"
         
    value="75678367229" size="15"><br>
    </td>
    <td><textarea id="newnode" rows="10" cols="80">
    <cd upc="75596280822">
      
    <artist>Phish</artist>
       <title>Live Phish, Vol. 15</title> 
       <price>26.99</price> 
       <label>ELEKTRA/WEA</label>
       <date>2002-10-29</date>

    </cd>
    </textarea>
    </td>
    </tr>

    More XML Articles
    More By McGraw-Hill/Osborne


       · 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 2 hosted by Hostway
    Stay green...Green IT