am getting an error.
What is the type of xmlProductName (check the runtime type in the debugger)?
The debug output is as follows.
'DefaultDomain' : Loaded
'c:\winnt\micro soft.net\framew ork\v1.1.4322\m scorlib.dll', No symbols loaded.
'Zadig': Loaded 'C:\Documents and Settings\mlubra no\My Documents\Visua l
Studio Projects\Zadig\ bin\Zadig.exe', Symbols loaded.
'Zadig.exe': Loaded
'c:\winnt\assem bly\gac\system. windows.forms\1 .0.5000.0__b77a 5c561934e089\sy stem.windows.fo rms.dll', No symbols loaded.
'Zadig.exe': Loaded
'c:\winnt\assem bly\gac\system\ 1.0.5000.0__b77 a5c561934e089\s ystem.dll', No
symbols loaded.
'Zadig.exe': Loaded
'c:\winnt\assem bly\gac\microso ft.visualbasic\ 7.0.5000.0__b03 f5f7f11d50a3a\m icrosoft.visual basic.dll', No symbols loaded.
'Zadig.exe': Loaded
'c:\winnt\assem bly\gac\system. drawing\1.0.500 0.0__b03f5f7f11 d50a3a\system.d rawing.dll', No symbols loaded.
'Zadig.exe': Loaded
'c:\winnt\assem bly\gac\system. xml\1.0.5000.0_ _b77a5c561934e0 89\system.xml.d ll', No symbols loaded.
An unhandled exception of type 'System.Invalid CastException' occurred in
Zadig.exe
Additional information: Specified cast is not valid.
Unhandled Exception: System.InvalidC astException: Specified cast is not valid.
at Zadig.Products. AddProduct(XmlN ode node) in C:\Documents and
Settings\mlubra no\My Documents\Visua l Studio Projects\Zadig\ Products.vb:lin e
239
at Zadig.Products. bttnAdd_Click(O bject sender, EventArgs e) in
C:\Documents and Settings\mlubra no\My Documents\Visua l Studio
Projects\Zadig\ Products.vb:lin e 223
at System.Windows. Forms.Control.O nClick(EventArg s e)
at System.Windows. Forms.Button.On Click(EventArgs e)
at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)
at System.Windows. Forms.Control.W mMouseUp(Messag e& m, MouseButtons
button, Int32 clicks)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.ButtonBas e.WndProc(Messa ge& m)
at System.Windows. Forms.Button.Wn dProc(Message& m)
at System.Windows. Forms.ControlNa tiveWindow.OnMe ssage(Message& m)
at System.Windows. Forms.ControlNa tiveWindow.WndP roc(Message& m)
at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G& msg)
at
System.Windows. Forms.Component Manager.System. Windows.Forms.U nsafeNativeMeth ods+IMsoCompone ntManager.FPush MessageLoop(Int 32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows. Forms.ThreadCon text.RunMessage LoopInner(Int32 reason,
ApplicationCont ext context)
at System.Windows. Forms.ThreadCon text.RunMessage Loop(Int32 reason,
ApplicationCont ext context)
at System.Windows. Forms.Applicati on.Run(Form mainForm)
at Zadig.Zadig.Mai n() in C:\Documents and Settings\mlubra no\My
Documents\Visua l Studio Projects\Zadig\ Main.vb:line 3The program '[328]
Zadig.exe' has exited with code 0 (0x0).
"fremenusul " <fr********@dis cussions.micros oft.com> wrote in message
news:40******** *************** ***********@mic rosoft.com...
Now I am getting this error
Additional information: Specified cast is not valid.
error begins on this line
node.AppendChil d(xmlProductNam e)
Thanks for the help.
Michae
"Sean Hederman" wrote:Whoops! That was silly, rather do:
AddProduct(xmlD oc.ChildNodes(0 ))
It'll be faster than using XPath.
"fremenusul " <fr********@dis cussions.micros oft.com> wrote in message
news:79******** *************** ***********@mic rosoft.com...>I know I have been asking LOTS of xml questions and I really apprecaite
>all
> the help.
>
> Here is my XML file
> <?xml version="1.0" encoding="utf-8" ?>
>
> <products>
> <!-- Repeat the structure below for each product. -->
> <product>
> <id>CP-90, T-32</id>
> <company>Carwel l</company>
> <address>Stre et Address</address>
> <city>City</city>
> <state>State</state>
> <zip>Zip</zip>
> </product>
>
> <!-- Next product here-->
> </products>
>
>
> I am loading the doc in memory using xmlDocument
> Dim xmlFile As String = xmlLocation()
> Dim xmlDoc As XmlDocument
>
> Private Sub Products_Load(B yVal sender As System.Object, ByVal e As
> System.EventArg s) Handles MyBase.Load
> xmlDoc = New XmlDocument
> xmlDoc.Load(xml File)
>
>
> End Sub
>
> Here is when my problem starts. I have a form with all the information
> that
> I needed "appended" to the XMLdoc (in memory). I tried
>
> Private Sub AddProduct(ByVa l node As XmlNode)
> Dim xmlProductName = txtProduct.Text
> Dim xmlCompanyName = txtCompany.Text
> Dim xmlAddress = txtAddress.Text
> Dim xmlCity = txtCity.Text
> Dim xmlState = cmboState.Text
> Dim xmlZip = txtZip.Text
> node.AppendChil d(xmlProductNam e)
> node.AppendChil d(xmlCompanyNam e)
> node.AppendChil d(xmlAddress)
> node.AppendChil d(xmlCity)
> node.AppendChil d(xmlState)
> node.AppendChil d(xmlZip)
> End Sub
>
> But I am really confused on what node to pass. Any help would be
> apprciated.