Guys, simple one, where am I going wrong with creating this xml???
This is what I want.....
This is what I'm getting....Code:<0A0B1264510C0D23_15012009_status> <ptev_g01_01> <ptev_g01_com>"testing comments"<\ptev_g01_com> <ptev_g01_cat>"C"<\ptev_g01_cat> <ptev_g01_vds>"53535353"<\ptev_g01_vd> <ptev_g01_yesno>"Yes"<\ptev_g01_yesno> <\ptev_g01_01>
And heres the code that creates it...Code:<?xml version="1.0"?> <0A0B1264510C0D23_15012009_status> <ptev_g01_01 ptev_g01_com="testing comments" ptev_g01_cat="P" ptev_g01_vds="1234567" ptev_g01_yesno="Yes" /> <ptev_g01_02 ptev_g01_com="" ptev_g01_cat="" ptev_g01_vds="" ptev_g01_yesno="" /> <ptev_g01_03 ptev_g01_com="" ptev_g01_cat="" ptev_g01_vds="" ptev_g01_yesno="" /> <ptev_g01_04 ptev_g01_com="" ptev_g01_cat="" ptev_g01_vds="" ptev_g01_yesno="" /> <ptev_g01_05 ptev_g01_com="" ptev_g01_cat="" ptev_g01_vds="" ptev_g01_yesno="" />
Code:' Create the root node of a new XML document. Dim xml As New XmlDocument ' Use the XmlDeclaration class to place the ' <?xml version="1.0"?> declaration at the top of our XML file Dim dec As XmlDeclaration = xml.CreateXmlDeclaration("1.0", Nothing, Nothing) xml.AppendChild(dec) 'Create root node xmls_parent = str_objectid & "_" & Replace(lbl_DateCompleted.Text, "/", "") & "_" & "status" Dim DocRoot As XmlElement = xml.CreateElement(xmls_parent) xml.AppendChild(DocRoot) Dim acp As AccordionPane For Each acp In accMain.Panes 'get all question data and append to question node Dim QListview As ListView = TryCast(acp.FindControl("lstQuestions"), ListView) For Each itm As ListViewItem In QListview.Items 'Add a question child node Dim question As XmlNode = xml.CreateElement("ptev_g" & Format(xml_section, "00").ToString & "_" & Format(xml_question, "00").ToString) Dim Qcontrol As QuestionsControl = TryCast(itm.FindControl("customControl"), QuestionsControl) Dim newAtt As XmlAttribute newAtt = xml.CreateAttribute("ptev_g" & Format(xml_section, "00").ToString & "_com") newAtt.Value = Qcontrol.QComment question.Attributes.Append(newAtt) newAtt = xml.CreateAttribute("ptev_g" & Format(xml_section, "00").ToString & "_cat") newAtt.Value = Qcontrol.QCategory question.Attributes.Append(newAtt) newAtt = xml.CreateAttribute("ptev_g" & Format(xml_section, "00").ToString & "_vds") newAtt.Value = Qcontrol.QVDSCode question.Attributes.Append(newAtt) newAtt = xml.CreateAttribute("ptev_g" & Format(xml_section, "00").ToString & "_yesno") newAtt.Value = Qcontrol.QYesno question.Attributes.Append(newAtt) DocRoot.AppendChild(question) xml_question = xml_question + 1 Next xml_question = 1 xml_section = xml_section + 1 Next xml.Save("c:\PartEval.xml")




Reply With Quote