Results 1 to 4 of 4

Thread: [2008] Creating XML

Threaded View

  1. #1

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    [2008] Creating XML

    Guys, simple one, where am I going wrong with creating this xml???

    This is what I want.....
    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>
    This is what I'm getting....
    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="" />
    And heres the code that creates it...


    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")
    Last edited by staticbob; Jan 15th, 2009 at 04:46 PM.
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width