vb6 - add a child to an xml file using vb 6.0 -


this source code generates xml each new node attached root want nodes nested.

rem-add info child node ver 1a 6/24/15-next sample code 5/29/15

private sub form_load() dim dom, node, attr

on error goto errorhandler  set dom = createdom   set node = nothing  ' create comment document. set node = dom.createcomment("sample xml file need child , sub child.") dom.appendchild node set node = nothing  ' create root element. dim root set root = dom.createelement("returnstate")  ' create "created" attribute root element , ' assign "using dom" character data attribute value. set attr = dom.createattribute("stateschemaversion") attr.value = "fsetv5.0" root.setattributenode attr set attr = nothing  ' add root element dom instance. dom.appendchild root ' insert newline + tab. root.appendchild dom.createtextnode(vbnewline) ' create , add more nodes root element created. ' create text element. set node = dom.createelement("submissionid") node.text = "1026132015623subid" ' add text node root element. root.appendchild node set node = nothing   ' add newline plus tab. root.appendchild dom.createtextnode(vbtab)  ' create element  set node = dom.createelement("returnheaderstate")   set node1 = dom.createelement("jurisdiction") node1.text = "nys" ' add text node root element. node.appendchild node1 set node1 = nothing  set node1 = dom.createelement("timestamp") node1.text = "2013-24-06" ' add text node root element. node.appendchild node1 set node1 = nothing 

rem------------next varable ' create element set node2 = dom.createelement("paidpreparerinformation") 'node.appendchild node2: '6/23/15

set node1 = dom.createelement("datesigned") node1.text = "june 23 2015" ' add text node root element. node2.appendchild node1 set node1 = nothing  set node1 = dom.createelement("timestamp") node1.text = "2013-24-06:12:36.23" ' add text node root element. node2.appendchild node1 

dom.documentelement.appendchild node2

set node2 = nothing   rem---replaced after sec node dom.documentelement.appendchild node ''set node = nothing   rem-removed because of line above 

'' dom.documentelement.appendchild node1 set node = nothing ' add newline plus tab. root.appendchild dom.createtextnode(vbnewline + vbtab)

rem------------end next vara

' create element hold 3 empty subelements. set node = dom.createelement("node3")  ' create document fragment added node3. set frag = dom.createdocumentfragment     ' add newline + tab + tab. frag.appendchild dom.createtextnode(vbnewline + vbtab + vbtab) frag.appendchild dom.createelement("subnode1")    ' add newline + tab + tab. frag.appendchild dom.createtextnode(vbnewline + vbtab + vbtab) frag.appendchild dom.createelement("subnode2")    ' add newline + tab + tab. frag.appendchild dom.createtextnode(vbnewline + vbtab + vbtab) frag.appendchild dom.createelement("subnode3")    ' add newline + tab. frag.appendchild dom.createtextnode(vbnewline + vbtab) node.appendchild frag set frag = nothing  root.appendchild node    ' add newline. root.appendchild dom.createtextnode(vbnewline) set node = nothing  ' save xml document file. dom.save app.path + "\testforchild.xml" set root = nothing set dom = nothing exit sub 

errorhandler: msgbox err.description end sub

rem----this source code generates

enter code here- enter code here</code> --> -
1026132015623subid - june 23 2015 2013-24-06:12:36.23 - nys 2013-24-06 -

       rem---------this want         rem   want returnheaderstate have children additonal     nodes        rem   paidpreparerinformation, has addtional nodes date, name,        rem   address not off root.  want them inside returnheaderstate node.             - <!-- sample xml file need child , sub child.         -->         - <returnstate stateschemaversion="fsetv5.0">           <submissionid>1026132015623subid</submissionid>          - <returnheaderstate>          <jurisdiction>nys</jurisdiction>           <timestamp>2013-24-06</timestamp>         - <paidpreparerinformation>         <datesigned>june 23 2015</datesigned>          <timestamp>2013-24-06:12:36.23</timestamp>          </paidpreparerinformation>         - <node3>         <subnode1 />          <subnode2 />          <subnode3 />          </node3>          </returnheaderstate>          </returnstate>                 <returnheaderstate>        <jurisdication>nys</jurisdication>        <timestamp>2015-06</timestamp>        <paidpreinfo> 


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -