Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

CreateAppendElement - appending a XmlElement under another XmlNode
[ All Languages » VB.net »  XML]

Total Hit ( 2787)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
' Create an XmlElement object with inner text and make it a child of another
' XmlNode.
' Note: requires Imports System.Xml

Function CreateAppendElement(ByVal parentNode As XmlNode, ByVal name As String, _
  Optional ByVal innerText As String = Nothing) As XmlElement
  ' Create a new XmlElement object, set the return value.
  Dim xmlEl As XmlElement = parentNode.OwnerDocument.CreateElement(name)
  ' Set its inner text
  If Not (innerText Is Nothing) Then xmlEl.InnerText = innerText
  ' make it a child of its parent node.
  parentNode.AppendChild(xmlEl)
  ' Return the new node to the caller
  Return xmlEl
End Function


' Example:

' load a XML file
Dim xmldoc As New XmlDocument()
xmldoc.Load("Employees.xml")

' create new Employee element and set its attributes
Dim xmlEl As XmlElement = CreateAppendElement(xmldoc.DocumentElement, _
  "Employee")
xmlEl.SetAttribute("id", "100")
' create sub-elements
CreateAppendElement(xmlEl, "firstName", "Joe")
CreateAppendElement(xmlEl, "lastName", "Doe")


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.