Working w/ DataGridView Table in XML

jsurpless

Well-known member
Joined
Jul 29, 2008
Messages
144
Programming Experience
Beginner
Hi all

Hoping someone can help me out on this...

I've got a DataGridView that's configured like this to read from my Configuration.xml file

VB.NET:
Expand Collapse Copy
            MatchMakerXML_Dataset.ReadXml(Application.StartupPath & "\Configuration.xml")

            AutoCADDrawingBorderBlocks_DataView.DataSource = MatchMakerXML_Dataset
            AutoCADDrawingBorderBlocks_DataView.DataMember = "DrawingBorderBlocks"

The XML File looks like this...

VB.NET:
Expand Collapse Copy
<?xml version="1.0" standalone="yes"?>
<Configuration>
  <Associations>
    <ReferenceAttribute Association="Component" />
  </Associations>
  <DrawingBorderBlocks>
    <Block>TITLE_06</Block>
  </DrawingBorderBlocks>
  <DrawingBorderBlocks>
    <Block>NOTEBX</Block>
  </DrawingBorderBlocks>
  <DrawingBorderBlocks>
    <Block>REFBX</Block>
  </DrawingBorderBlocks>
  <DrawingBorderBlocks>
    <Block>REVBX</Block>
  </DrawingBorderBlocks>
  <DrawingBorderBlocks>
    <Block>TITLEBX</Block>
  </DrawingBorderBlocks>
  <DrawingBorderBlocks>
    <Block>ILD_BORDER</Block>
  </DrawingBorderBlocks>
  <Settings>
    <ModeOfOperation Setting="Population" />
  </Settings>
</Configuration>

I'd like to loop through the 'DrawingBorderBlocks' node(s) using XMLDocument... presently doing it like so

VB.NET:
Expand Collapse Copy
            Dim Configuration_XMLDoc As New XmlDocument()
            Dim Configuration_XMLDoc_Node As XmlElement

            Configuration_XMLDoc.Load(Application.StartupPath & "\Configuration.xml")
            Configuration_XMLDoc_Node = Configuration_XMLDoc.SelectSingleNode("/Configuration")

            For Each Node As XmlNode In Configuration_XMLDoc_Node

                If (Node.Name = "DrawingBorderBlocks") Then

                    For Each childNode As XmlNode In Node

                        AutoCAD_DrawingBorderBlocks.Add(childNode.InnerText)

                    Next

                End If

            Next

Seems a little inefficient to me; I tried using a .SelectSingleNode on "/Configuration/DrawingBorderBlocks' but that's only selecting the 1st node and not the remaining 5...

Thanks!
 
Let me ask this... is it a good idea to be mixing information pulled from a DataGridView AND other information in the same XML file?

I'm using .SetAttribute to write to the others but when I go to write down the Dataset of the DataGridView, these are getting overwritten because those attributes aren't updated in the snapshot Dataset...

It's almost like I need to find a way to only update the single portion of the XML?
 
Back
Top