ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  C Sharp
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
I have to create a windows application using C# .net to 
Modifiy the XML file. The application have to show the node 
and node value. plz help me.
 Question Submitted By :: Muralimoorthi
I also faced this Question!!     Rank Answer Posted By  
 
  Re: I have to create a windows application using C# .net to Modifiy the XML file. The application have to show the node and node value. plz help me.
Answer
# 1
r u modifying the XML file by progm....
if u r modifying the xml by prgm means u have to specify 
that excat XML path where it is located..
otherwise u can use static property
then u ll get it
 
Is This Answer Correct ?    2 Yes 0 No
Bala
 
  Re: I have to create a windows application using C# .net to Modifiy the XML file. The application have to show the node and node value. plz help me.
Answer
# 2
Try to understand this code so that u will get some idea 
how to change the data in the existing xml file.

using System;
using System.Xml;
using System.Text;

namespace ConsoleApplication1
{
   class Class1
   {
      [STAThread]
      static void Main(string[] args)
      {
         try
         {
            // Create an XML document instance, and load 
XML data.
            XmlDocument doc  = new XmlDocument();
            doc.Load
("Q317666.xml");                      // This code assumes 
that the XML file is in the same folder.

            // I. Modification
            // 1. Increment all of the Book Id attribute 
values by 100.
            XmlNodeList nodeList = doc.SelectNodes
("//Book");
            foreach (XmlNode node in nodeList)
               node.Attributes["Id"].Value = (Int32.Parse
(node.Attributes["Id"].Value) + 100).ToString();

            // 2. Change the book titles to uppercase 
letters.
            foreach (XmlNode node in nodeList)
               node.FirstChild.InnerText = 
(node.FirstChild.InnerText).ToUpper();

            // 3. Modify the XML declaration instruction to 
have Unicode encoding.
            XmlDeclaration decl = (XmlDeclaration) 
doc.FirstChild;
            decl.Encoding = "UTF-16";

            // II. Addition
            // 1. Create a new Book element.
            XmlElement newElem = doc.CreateElement("Book");

            // Add the Id attribute.
            XmlAttribute newAttr = doc.CreateAttribute
("Id");
            newAttr.Value = "103";
            newElem.Attributes.Append(newAttr);

            // Create the child nodes. This code 
demonstrates various ways to add them.
            newElem.InnerXml 
= "<Title></Title><Author></Author>";
            XmlText txtNode = doc.CreateTextNode("A BRIEF 
HISTORY OF TIME");
            newElem.FirstChild.AppendChild(txtNode);
            newElem.AppendChild(doc.CreateWhitespace
("\r\n")); // Linefeed
            newElem["Author"].InnerText = "Stephen Hawking";

            // 2.  Add the new element to the end of the 
book list.
            doc.DocumentElement.AppendChild(newElem);

            // III. Deletion
            // 1. Remove the Genre nodes from Book elements.
            foreach (XmlNode node in nodeList)
               node.RemoveChild(node.SelectSingleNode
("Genre"));

            // Display the output in Debug window.
            System.Diagnostics.Debug.Write("{0}\n", 
doc.OuterXml);

            // 2. Save the modified XML to a file in 
Unicode format.
            doc.PreserveWhitespace = true;
            XmlTextWriter wrtr = new XmlTextWriter
("Q317666_Out.xml", Encoding.Unicode);
            doc.WriteTo(wrtr);
            wrtr.Close();
         }
         catch(XmlException xmlEx)        // Handle the Xml 
exceptions here.         
         {
            Console.WriteLine("{0}", xmlEx.Message);
         }
         catch(Exception ex)              // Handle the 
generic exceptions. here
         {
            Console.WriteLine("{0}", ex.Message);
         }
      }
   }
}
 
Is This Answer Correct ?    1 Yes 1 No
Ravikiran Gullapalli
 
 
 

 
 
 
Other C Sharp Interview Questions
 
  Question Asked @ Answers
 
Error handling and how this is done ? Digital-GlobalSoft1
What?s the implicit name of the parameter that gets passed into the class? set method? Visual-Soft2
What is the difference between cookies and session? ADITI1
Explain the Scope of public/private/friend/protected/protected friend. Wipro1
What are the security issues if we send a query from the application? Microsoft1
What is the difference between readonly and constant in c# Fulcrum-Logic1
Will finally block get executed if the 1exception had not occurred?  2
What?s an abstract clas? Mind-Tree2
Why are there five tracing levels in System.Diagnostics.TraceSwitcher?  1
What?s a delegate?  1
What is the difference between directcast and ctype? Wipro2
What does assemblyinfo.cs consists ? Microsoft2
What?s a satellite assembly?  1
what is Encapsulation? Tech-Mahindra1
may we achieve polyphormsm through overloading a funtion?Is it right or wrong concept because i read polyphormism can be achieved through overloading?plz help me thnks  1
Hello.. This is kali prasad. i wish to learn C#. kindly guide me in making me expert in c#.  2
What is Dispose method in .NET ? TCS2
What are three test cases you should go through in unit testing? Wipro1
What?s the difference between // comments, /* */ comments and /// comments? Visual-Soft1
What is the Difference between value and reference type? Wipro5
 
For more C Sharp Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com