DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: HELP

  1. #1
    Souzana Papadopoulou Guest

    HELP


    Hi,

    I need to use VB to create an XML document using the "Microsoft XML, Version
    2.0" object.

    All I know how to do so far is: Dim xmlDoc As DOMDocument

    I need to create this structure:

    <XML>
    <ITEM1>
    <DATA>
    </ITEM1>
    <ITEM2>
    <DATA>
    </ITEM2>
    <GROUP1>
    <ITEM4>
    <DATA>
    </ITEM4>
    <ITEM5>
    <DATA>
    </ITEM5>
    </GROUP1>
    </XML>

    Can anyone help?

    Thanks,

    Souzana

  2. #2
    Phil Weber Guest

    Re: HELP

    > I need to use VB to create an XML document using the
    > "Microsoft XML, Version 2.0" object. I need to create this
    > structure...


    Souzana: Try this:

    Dim xmlDoc As DOMDocument
    Dim xmlRoot As IXMLDOMNode
    Dim xmlElement As IXMLDOMElement
    Dim xmlProperty As IXMLDOMElement

    Set xmlDoc = New DOMDocument
    xmlDoc.async = False
    xmlDoc.LoadXML "<xml></xml>"
    Set xmlRoot = xmlDoc.documentElement

    With xmlRoot
    Set xmlElement = xmlDoc.createElement("item1")
    Set xmlProperty = xmlDoc.createElement("data")
    xmlProperty.Text = "value"
    xmlElement.appendChild xmlProperty
    .appendChild xmlElement

    Set xmlElement = xmlDoc.createElement("item2")
    Set xmlProperty = xmlDoc.createElement("data")
    xmlProperty.Text = "value"
    xmlElement.appendChild xmlProperty
    .appendChild xmlElement
    End With
    xmlDoc.save sFileName

    For future reference, XML questions are most likely to be answered in our
    xml.general newsgroup. Thanks!
    ---
    Phil Weber



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center