473,806 Members | 2,319 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Append Child Nodes XML in Memory

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.
Jul 21 '05 #1
7 1869
AddProduct(xmlD oc.SelectSingle Node("/"))

/ is the XPath for the root node.

"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.

Jul 21 '05 #2
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.

Jul 21 '05 #3
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.


Jul 21 '05 #4
What is the type of xmlProductName (check the runtime type in the debugger)?

"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.


Jul 21 '05 #5
Here is my debug output.

'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 " wrote:
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.


Jul 21 '05 #6
That would generally be caused by you not passing an XmlNode into the
method. Please can you put a breakpoint onto AddProduct(XmlN ode node), and
let us know what runtime type is reported by VS.NET for the parameter being
passed in.

"fremenusul " <fr********@dis cussions.micros oft.com> wrote in message
news:8D******** *************** ***********@mic rosoft.com...
Here is my debug output.

'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 " wrote:
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.
>
>
>

Jul 21 '05 #7
Got the answer
(http://msdn.microsoft.com/newsgroups...9-5639e23d5cb4)

I do have another question about reading xml from memory though....
I am building a application that uses XML data to display prducts.

Currently, I have a class that holds the XML data.

Imports System.Xml

Public Class Settings

Private Shared xmlDoc As XmlDocument

Public Shared Property Products() As XmlDocument
Get
If xmlDoc Is Nothing Then
Dim xmlFile As String = xmlLocation()
Dim xmlDoc As XmlDocument

xmlDoc = New XmlDocument
xmlDoc.Load(xml File)
End If

Return xmlDoc
End Get
Set(ByVal Value As XmlDocument)

End Set
End Property

End Class

Here is where my problem begins. I have a form that has a combobox that will
display some of the xml data. If someone needs to add data a new form pops up
and they add data to the memory (xml). Then it saves the new XML file.

If they close the "add products" form, the combobox is NOT updated with the
new information. How can I have the combobox read the XML data (in memory)?

PS: here is how I was doing it before I added a class to hold XML data.
Private Sub Zadig_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

'Dim xmlTr As New XmlTextReader(x mlFile)

'While xmlTr.Read
' If xmlTr.Name = "id" AndAlso xmlTr.NodeType =
XmlNodeType.Ele ment Then
' cmbProducts.Ite ms.Add(xmlTr.Re adString)
' End If
'End While
'xmlTr.Close()

'xmlDoc = New XmlDocument
'xmlDoc.Load(xm lFile)

End Sub

I dont think I can do it in the "load" area because it is only loaded once.
I need something that will be "dynamic" with the combobox.

"Sean Hederman" wrote:
That would generally be caused by you not passing an XmlNode into the
method. Please can you put a breakpoint onto AddProduct(XmlN ode node), and
let us know what runtime type is reported by VS.NET for the parameter being
passed in.

"fremenusul " <fr********@dis cussions.micros oft.com> wrote in message
news:8D******** *************** ***********@mic rosoft.com...
Here is my debug output.

'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 " wrote:
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.
>
>
>


Jul 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1751
by: Manisha | last post by:
Hi, I am creating a C++ dll which is used to process data passed to it through one of its exported functions. It should be able to process 160 simultaneous requests. For this reason, I have initiated 10 child threads from the main thread and maintaining a queue of nodes containing the data to be processed. The queue node strucute is as follows: struct SQueueNode
13
4172
by: kaeli | last post by:
Can anyone explain this to me? It's driving me insane. Save this and run it in IE or Opera and then in Mozilla or Netscape 6+. In IE/Opera, I get the expected 4 alerts. In Mozilla/Netscape, I get *9*. In the example table, there are 4 rows with 4 columns each in the tbody. I'd expect 4 child nodes for the table body with 4 children each. I get those 4 plus 5 alerts in Mozilla/Netscape. I get only those 4 in IE and Opera. Note that...
2
1667
by: Scott | last post by:
hi friend's, i m new in both things php and in this group. but i have some basic knowledge of php and DOM in php. here is my problem, i have one textfield for add a new main node (not main like: <root><this_one></this_one></root>) in my php page and i m able to save the xml file correct with this, and in the bottom of that i have one new textfield for add new child in dynamically create node (which i descibe above),and one combo box for...
3
23962
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
10
2661
by: Rich Wallace | last post by:
I'm sure there's a very weasy way to do this, I've been running hard and fast on several things at once and just may be at the point of overthinking this... I receive an incoming XML document via a string feed within a web service: <Root> <Product> <File>Order</File> <Origin>OregonOffice</Origin>
12
20535
by: Dino L. | last post by:
I am putting data from DataTable to treeView foreach( DataRow aRow in aTable.Rows) { TreeNode tnode = new TreeNode(aRow.ToString() + aRow.ToString() + " " + aRow.ToString()); treeView1.Nodes.Add(tnode); //till here code works fine //now I wanna add child nodes for last inserted node foreach( DataRow GrupaRow in TabelaGrupe.Rows)
7
3775
by: amruta | last post by:
the code below dows not let me get the parent child view... all the nodes are show in one line only... also i need them to be collasped ... Thanks ..
7
359
by: fremenusul | last post by:
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>
1
2332
by: Daniel Rucareanu | last post by:
Hello, Does anybody knows how can you delete, in just one step, not using a loop, a subset of the child nodes of a given DOM parent node? The subset will be continous, so for example, if the parent node has 100 nodes, I want to delete nodes 10 through 75, and not nodes 5, 10, 25 etc. I have a reference to the first and the last node in the list that has to be removed. Also it's position in the list, if that helps.
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.