I'v been reading and reading on this subject an from what iv got so far, you add a Node and then append elements to that new node which then appends to the parent node. My current schema for my xml document is as follows:
The Xml Structure is
<Queries>
<Query>
<Name> Query Name </Name>
<Action></Action>
<Text>
I basically am getting the above values from input via textbox input. What i want is to add a <Query> node with the values inputted from a textbox. Im just unsure of how to create this structure in vb.net... This is the code i have so far.
Public Sub AppendNewQuery(ByVal doc As XmlDocument)
Dim newQueryNode As XmlNode = QueryList.XMLDoc.CreateNode(XmlNodeType.Element, "Query", Nothing)
'newQueryNode.InnerText = "Text from Query Name TextBox"
Dim QueryName As XmlNode = QueryList.XMLDoc.CreateElement("Name")
QueryName.InnerText = NewQueryNameTXT.Text
Dim QueryAction As XmlNode = QueryList.XMLDoc.CreateElement("Action")
QueryAction.InnerText = NewQueryActionTXT.Text
Dim QueryText As XmlNode = QueryList.XMLDoc.CreateElement("Text")
QueryText.InnerText = QueryEditor.Text
I have also resolved this myself, code i used is below...of course there is more to it but this is the heart of how it works.
Dim paramEleName As XmlNode = QueryList.XMLDoc.CreateElement("Name")
Dim paramEleType As XmlNode = QueryList.XMLDoc.CreateElement("DataType")
Dim paramEleDisplay As XmlNode = QueryList.XMLDoc.CreateElement("DisplayName")
Dim parameter As ParameterBL = r.DataBoundItem
paramEleName.InnerText = parameter.Name.ToString
paramEleType.InnerText = parameter.DataType.ToString
paramEleDisplay.InnerText = parameter.DisplayName.ToString
parameterNode.AppendChild(paramEleName)
parameterNode.AppendChild(paramEleType)
parameterNode.AppendChild(paramEleDisplay)
ParametersRootNode.AppendChild(parameterNode)
Bookmarks