Here's a little progress, I just need the touchdown hint!!
-------------------------Begin Code-------------------------
Dim xmlConfig As New XmlDocument
xmlConfig.Load("http://localhost/myapp/Config.xml")
Dim nodeList As XmlNodeList =
xmlConfig.SelectNodes("//myappInfo/UserName")
Dim node As XmlNode
Dim listItem As ListItem
For Each node In nodeList
If node.InnerXml = Me.ddlDivision.SelectedItem.Text Then
node.Attributes.RemoveAll() 'Remove current attributes of
selected user and re-populate
For Each listItem In Me.listSelected.Items
Dim newElem As XmlElement =
xmlConfig.CreateElement("Field")
Dim newAttrib As XmlAttribute =
xmlConfig.CreateAttribute("Name")
newAttrib.Value = listItem.Text
newElem.Attributes.Append(newAttrib)
xmlConfig.DocumentElement.AppendChild(newElem)
Next
End If
Next
-------------------------EndCode-------------------------
Here's the end result:
<myappConfig>
<UserInfo>
<DivisionName>Northern California</DivisionName>
<DivisionCode>SJ</DivisionCode>
<ReportAttributes>
<ReqdFields/>
</ReportAttributes>
</UserInfo>
<UserInfo>
<DivisionName>Tampa</DivisionName>
<DivisionCode>TF</DivisionCode>
<ReportAttributes>
<ReqdFields/>
</ReportAttributes>
</UserInfo>
<Field Name="Project"/>
<Field Name="Builder"/>
</myappConfig>
So...now that I'm able to add the new elements "Field" and attributes
"Name", how can I get this data into the correct ReqdFields node based on
the selected DivisionName in the app??
TIA
-Rich
"Rich Wallace" <rich.wallace@minusthecannedmeat.jfsheadotcom> wrote in
message news:eP0oFXelEHA.324@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view] > Hi all,
>
> I've been though many posts in this group and have yet to find one that
> helps me understand how to accomplish my goal.
>
> I have an XML document that stores user specific values that I need to
> maintain based on options they select in a web app. Here's the XML:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <MyConfig>
> <UserInfo>
> <UserName>Joe Schmoe</UserName>
> <ReportAttributes>
> <ReqdFields>
> <Field Name="Address"/>
> <Field Name="City" />
> <Field Name="Close_Date" />
> <Field Name="FName1" />
> <Field Name="FName2" />
> <Field Name="Project" />
> <Field Name="State" />
> <Field Name="Zip" />
> </ReqdFields>
> </ReportAttributes>
> </UserInfo>
> </MyConfig>
>
> A form in the web app displays all available fields that the user can
select
> as a valid 'ReqdFields' option or remove them from teh list as well. How
> can I update the XML and remove or add the updated fields via .NET code to
> reflect the changes??
>
> TIA
> -Rich
>
>