Ok lets say i have the following xml file

     <Users>
            <User>
                <Name>Jonathan</Name>
                <Tests>
                </Tests>
            </User>
            <User>
                <Name>John</Name>
                <Tests>
                </Tests>
            </User>
        </Users> 

Im writing a C# program, and what I want is to search for a specific name(eg Jonathan) and add elements and values to that specific tag in my xml file.
For Example after adding those elements and values in C#, my xml file would look something like this

        <Users>
            <User>
                <Name>Jonathan</Name>
                <Tests>
                    <Test>
                        <Grade>ten</Grade>
                        <Time>twenty</Time>
                    </Test>
                </Tests>
            </User>
            <User>
                <Name>John</Name>
                <Tests>
                </Tests>
            </User>
      </Users>

I could keep adding scores and times according to the person i want to search for.This is the code i have so far,I would appreciate if someone helps me out, Im fairly new to C#.

 XmlDocument doc = new XmlDocument();
            doc.Load("users.xml");
            XmlNode test = doc.CreateNode(XmlNodeType.Element, "Test", null);

            XmlNode grade = doc.CreateNode(XmlNodeType.Element, "Grade", null);
            grade.InnerText = "ten";
            XmlNode time = doc.CreateNode(XmlNodeType.Element,"Time",null);
            time.InnerText = "twenty";

SO basically I want to add this Nodes and Values to a specific location in my xml file.
Thanks in advance.

Have you read the documentation for the XmlDocument class? It has methods for doing everything you want.

thanks i actually got it resolved, I have another issue now which i already posted in a new discussion

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.