9
Reply

Appending new tag and attribute values to the existing xml file through code behind

mahesh

mahesh

Jul 25 2011 6:57 AM
1.6k
Dear All,
           I want to append tag and attribute values to the existing xml file.Here is my code


        Strpath = AppDomain.CurrentDomain.BaseDirectory.ToString & "data.xml"
        Dim doc As XDocument = XDocument.Load(Strpath)
        Dim xmlnode As XElement = doc.<Strpath>(0)
        'Dim xmleleattr As XElement
        Dim xmleleattr As XElement = _
        <Student>
            <Name>
                <%= David %>
            </Name>
            <Address>
                <%= Royal street %>
            </Address>
            <PhoneNumber>
                <%= 98767896%>
            </PhoneNumber>
            <Email>
                <%= [email protected]%>
            </Email>
        </Student>
        xmlnode.Add(New XElement(xmleleattr)) // in this line i,m getting an error that object reference not set to an instance of an object.

        xmlnode.Save(Strpath)

Thanks in advance.




          

Answers (9)