Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to insert the data into xml file using asp.net with vb.net [modified]

how to insert the data into xml file using asp.net with vb.net [modified]

Scheduled Pinned Locked Moved ASP.NET
csharphtmlasp-netxml
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vbmadhavi
    wrote on last edited by
    #1

    hello everybody. i want to insert the data into xmlfile.how it possible. i developed code for this .but i dont know whether it is correct or not. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' Create xml dom Dim XMLDom As New XmlDocument() 'this xml file is already i created. XMLDom.Load("D:\XMLFILE1.xml") 'Selecting the main node Dim newXMLNode As XmlNode = XMLDom.SelectSingleNode("persons") '''''''get the node where i want to insert the data Dim childNode As XmlNode = XMLDom.CreateNode(XmlNodeType.Element, "p", "") ''''''''In the below step "p" is my node name and "sree" is my data to insert Dim newAttribute As XmlAttribute = XMLDom.CreateAttribute("p", "sree", "") childNode.Attributes.Append(newAttribute) newXMLNode.AppendChild(childNode) end sub when i run this code error occured i.e Object reference not set to an instance of an object. this error is occured in newXMLNode.AppendChild(childNode)

    modified on Thursday, February 25, 2010 2:09 AM

    P 1 Reply Last reply
    0
    • V vbmadhavi

      hello everybody. i want to insert the data into xmlfile.how it possible. i developed code for this .but i dont know whether it is correct or not. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' Create xml dom Dim XMLDom As New XmlDocument() 'this xml file is already i created. XMLDom.Load("D:\XMLFILE1.xml") 'Selecting the main node Dim newXMLNode As XmlNode = XMLDom.SelectSingleNode("persons") '''''''get the node where i want to insert the data Dim childNode As XmlNode = XMLDom.CreateNode(XmlNodeType.Element, "p", "") ''''''''In the below step "p" is my node name and "sree" is my data to insert Dim newAttribute As XmlAttribute = XMLDom.CreateAttribute("p", "sree", "") childNode.Attributes.Append(newAttribute) newXMLNode.AppendChild(childNode) end sub when i run this code error occured i.e Object reference not set to an instance of an object. this error is occured in newXMLNode.AppendChild(childNode)

      modified on Thursday, February 25, 2010 2:09 AM

      P Offline
      P Offline
      Prosanta Kundu online
      wrote on last edited by
      #2

      Hi, Check "newXMLNode" is null or not. Thanks Prosanta

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups