manipulation XML avec vb.net
	
	
		Bonjour ,
Je suis un débutant en vb.net, et  reprenant le tutorial http://selkis.developpez.com/tutoriels/dotnet/Xmlpart1/ une exception est generée : au niveau de la ligne 
	Code:
	
XmlDoc.DocumentElement.AppendChild(elemSite)
 du code 
	Code:
	
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 
 |  Dim XmlDoc As XmlDocument = New XmlDocument()
 
        Dim elemSite As XmlElement
        elemSite = XmlDoc.CreateElement("SITE")
 
        'creation et definition de la balise url (enfant)
        Dim elemUrl As XmlElement
        elemUrl = XmlDoc.CreateElement("URL")
        elemUrl.InnerText = " http://www.peuw.net/index.xml "
 
        'creation et definition de la balise Nom (enfant)
        Dim elemNom As XmlElement
        elemNom = XmlDoc.CreateElement("NOM")
        elemNom.InnerText = "peuw.net"
 
        'ajout des 2 balise enfants a la balise parent 
        elemSite.AppendChild(elemUrl)
        elemSite.AppendChild(elemNom)
        MsgBox(XmlDoc.ToString)
        'on ajoute la balise parent au document
        XmlDoc.DocumentElement.AppendChild(elemSite)
 
        'Ecriture du Xml
        XmlDoc.Save(Application.StartupPath & "Newsite.XML")
        MsgBox("Enregistrement réussi") | 
 détail de l'exception 
	Code:
	
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 
 | L'exception System.NullReferenceException n'a pas été gérée
  Message="La référence d'objet n'est pas définie à une instance d'un objet."
  Source="Mon_projet"
  StackTrace:
       à locationAssistance.Form1.KryptonButton2_Click(Object sender, EventArgs e) dans C:\Users\Barad3i\Desktop\locationAssistance_15102008_0636\locationAssistance_14102008_0214\Form1.vb:ligne 65
       à System.Windows.Forms.Control.OnClick(EventArgs e)
       à ComponentFactory.Krypton.Toolkit.KryptonButton.OnClick(EventArgs e)
       à ComponentFactory.Krypton.Toolkit.KryptonButton.b(Object A_0, MouseEventArgs A_1)
       à ComponentFactory.Krypton.Toolkit.ButtonController.OnClick(MouseEventArgs e)
       à ComponentFactory.Krypton.Toolkit.ButtonController.MouseUp(Control c, Point pt, MouseButtons button)
       à ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
       à ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
       à ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
       à ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
       à ComponentFactory.Krypton.Toolkit.ViewManager.MouseUp(MouseEventArgs e, Point rawPt)
       à ComponentFactory.Krypton.Toolkit.VisualControlBase.OnMouseUp(MouseEventArgs e)
       à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       à System.Windows.Forms.Control.WndProc(Message& m)
       à ComponentFactory.Krypton.Toolkit.VisualControlBase.WndProc(Message& m)
       à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       à System.Windows.Forms.Application.Run(ApplicationContext context)
       à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       à locationAssistance.My.MyApplication.Main(String[] Args) dans 17d14f5c-a337-4978-8281-53493378c1071.vb:ligne 81
       à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       à System.Threading.ThreadHelper.ThreadStart()
  InnerException: | 
 Quelq"un a une idée ?