C sharp XML question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cubanoemg
    New Member
    • Jul 2010
    • 2

    C sharp XML question

    Hello All

    I have the following xml:
    Code:
    <menu>
    	
      <photo image="http://bytes.com/images/tundra-2wd.jpg" url="http://www.example.com" target="_blank"><![CDATA[Test drive it!!]]></photo>
    
      <photo image="http://bytes.com/images/tundra.jpg" url="http://www.example.com" target="_blank"><![CDATA[Test drive it!!]]></photo>
    
    </menu>
    An i want to insert another elemnt like this:
    Code:
      <photo image="http://bytes.com/images/new.jpg" url="http://www.new.com" target="_blank"><![CDATA[new!!]]></photo>
    So it will look like this:
    Code:
    <menu>
    	
      <photo image="http://bytes.com/images/tundra-2wd.jpg" url="http://www.example.com" target="_blank"><![CDATA[Test drive it!!]]></photo>
    
      <photo image="http://bytes.com/images/tundra.jpg" url="http://www.example.com" target="_blank"><![CDATA[Test drive it!!]]></photo>
    
      <photo image="http://bytes.com/images/new.jpg" url="http://www.new.com" target="_blank"><![CDATA[new!!]]></photo>
    
    </menu>
    How do I achieve this in C Sharp and ASP.net
    Last edited by Curtis Rutland; Jan 7 '11, 10:28 PM.
  • HaLo2FrEeEk
    Contributor
    • Feb 2007
    • 404

    #2
    You need to end and re-start your code tags for each portion of code that you want to post. Also, you could eliminate all of the blank in your posted code, reducing 29 lines down to 10.

    Before I give you any information as to what you should do, convince me that you've tried. We're not going to do your work for you unless we see that you've tried to figure it out on your own.

    Comment

    • GaryTexmo
      Recognized Expert Top Contributor
      • Jul 2009
      • 1501

      #3
      I agree with Halo that you should clean up your OP so that other people coming in and seeing your thread have an easier time of reading it :)

      As for your actual question, you'll want to take a look at the AppendChild method of the XmlNode object. Here's an MSDN link...



      (It's worth noting that while an example is provided, that may not be exactly what you need. This should put you on the right track though... if you have troubles, please let us know!)

      Comment

      • HaLo2FrEeEk
        Contributor
        • Feb 2007
        • 404

        #4
        And to supplement Gary's last statement (in parentheses), if the example provided on that page isn't exactly what you need, then try to figure out the problem with the information you have been given. Google is an absolute Godsend in situations like this, use it! We're not here to do your work for you, but we want to help you learn. Show us that you want to learn HOW to do it and now just have it done for you, and we'll be more than happy to help.

        Comment

        Working...