storing an xml element

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NotYetaNurd

    storing an xml element

    I have a situation , where in I had to store a bit of information about a
    treenode in Tag .....

    like this
    "<shorcut key="M1" startpos="33" >System.Windows .MessageBox.Sho w("");
    </shorcut>"

    ideally i should be creating an xmlelement add attributes and store the
    xmlelement in Tag...

    but am not able to do this
    i tried
    XmlElement xle = new XmlElement();
    but got this exception
    'System.Xml.Xml Element.XmlElem ent()' is inaccessible due to its protection
    level ...

    How do i declare an xmlelement and add attributes to it and then add to Tag
    Property ..

    Regards





  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: storing an xml element

    NotYetaNurd,

    You have to call the CreateElement method on the XmlDocument class that
    you want to add it to. Remember, you have to add the element to the node
    using the Append method once you have created your element.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "NotYetaNur d" <NotYetaNurd@Ma trix.com> wrote in message
    news:ubu%23pAUQ DHA.1712@TK2MSF TNGP12.phx.gbl. ..[color=blue]
    > I have a situation , where in I had to store a bit of information about a
    > treenode in Tag .....
    >
    > like this
    > "<shorcut key="M1" startpos="33" >System.Windows .MessageBox.Sho w("");
    > </shorcut>"
    >
    > ideally i should be creating an xmlelement add attributes and store the
    > xmlelement in Tag...
    >
    > but am not able to do this
    > i tried
    > XmlElement xle = new XmlElement();
    > but got this exception
    > 'System.Xml.Xml Element.XmlElem ent()' is inaccessible due to its protection
    > level ...
    >
    > How do i declare an xmlelement and add attributes to it and then add to[/color]
    Tag[color=blue]
    > Property ..
    >
    > Regards
    >
    >
    >
    >
    >[/color]


    Comment

    Working...