开发者

VB.NET 2010 Express Dataset/Dataview problems with XML

I am a co-op student learning vb.net and I have a project which retrieves data from an xml file within the program (based on selections made from combo boxes) and calculates and displays prices.

My XML looks like this:

<.Root>

....<.Processes>

........<.Process>12345<./Process >

........<.12345Material_Process>This Process<./12345Material_Process >

........<.Rate>20<./Rate >

........<.Type>Nitrogen<./Type >

........<.Dia>0.125<./Dia >

.

.

.

...<./Processes>

....<.Machines>

........<.Machine>AB12345

........<.Machine_Type>12345 4000 <./Machine_Type >

........<.AB12345Bed_Size>4000<./AB12345Bed_Size >

........<.Base_Price>$831.00<./Base_Price >

.

.

.

....<./Machines>

<./Root>

*Periods are for display (Couldn't figure out how to display xml code, I am that new with code!)

I have one combobox that loads data from the Processes section just fine, but then another uses the same method and gets an "IndexOutOfRange" error or "开发者_Python百科Column AB12345Bed_Size Not Found" even though I am using the same method for both. For "Processes" I am using DataView.Sort on "<12345Material_Process>" which reflects the selecteditem in the combobox. The program retrieves that row without a problem. Here is the code that is giving me a problem:

   Dim xmlFile As XmlReader    
   xmlFile = XmlReader.Create("File.xml", New XmlReaderSettings())  
   Dim ds As New DataSet  
   Dim dv As DataView  
   ds.ReadXml(xmlFile)  

   dv = New DataView(ds.Tables(0))
   dv.Sort = strName & "Bed_Size"
   Dim index As Integer = dv.Find(cmbSize.SelectedItem)  

I have read msdn and tried to make sense of it, as well as searching through many forums and examples.

Any help is GREATLY appreciated.


So obviously I don't know XML very well. I renamed the "<.Machines>" tags as "<.Processes>" and now it works. Now that I think about it I had a similar problem before.
So I guess I'd better sign up early for that XML class next term!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜