1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: VB.net 2003, creating xml using DOM, set value

Discussion in 'Software Development' started by Mike Beale, Nov 13, 2007.

Thread Status:
Not open for further replies.
  1. Mike Beale

    Mike Beale Thread Starter

    Joined:
    Oct 27, 1999
    Messages:
    79
    Hi,

    I'm creating some XML in VB.net 2003, using the DOM.

    This is the XML I'm trying to create:
    <items>
    <item id="1" title="some title"><![CDATA[And here is the description]]></item>
    <item id="2" title="Another one"><![CDATA[Description goes here]]></item>
    </items>

    Here is what I have so far:
    Dim xmlDoc As New XmlDocument
    xmlDoc.AppendChild(xmlDoc.CreateElement("", "items", ""))
    Dim xmlRoot As XmlElement = xmlDoc.DocumentElement
    Dim xmlItem As XmlElement

    xmlItem = xmlDoc.CreateElement("item")
    With xmlItem
    .SetAttribute("id", "1")
    .SetAttribute("title", "some title")
    End With
    xmlRoot.AppendChild(xmlItem)

    (in a loop for each item)

    This gives me:
    <items>
    <item id="1" title="some title"></item>
    <item id="2" title="Another one"></item>
    </items>

    But no way can I figure out how to add the text for the description.

    Any ideas?

    Thanks
    Mike
     
  2. Mike Beale

    Mike Beale Thread Starter

    Joined:
    Oct 27, 1999
    Messages:
    79
    For info, I have the solution from another forum:

    xmlItem.AppendChild(xmlDoc.CreateCDataSection("And here is the description"))

    This can be closed
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/651285

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice