CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies

Search Interview Questions

Question: How u can create XML file?

Answer: To write Dataset Contents out to disk as an XML file use:

MyDataset.WriteXML(server.MapPath("MyXMLFile.xml"))



Category DotNet Interview Questions & Answers - Exam Mode / Learning Mode
Rating (0.6) By 621 users
Added on 7/28/2011
Views 7957
Rate it!
Question: How u can create XML file?


Answer:

To write Dataset Contents out to disk as an XML file use:

MyDataset.WriteXML(server.MapPath("MyXMLFile.xml"))
Source: CoolInterview.com


dataSet.WriteXml(string path); Source: CoolInterview.com

Answered by: Bimal Chandra Patel | Date: 12/28/2007 | Contact Bimal Chandra Patel Contact Bimal Chandra Patel

string str = "";

string s="select * from emp";
SqlCommand cmd = new SqlCommand(s, con);
SqlDataReader dr = cmd.ExecuteReader();
//str += " <?xml version="1.0" encoding="UTF-8"?><Employee>" ;
str += "<Employee>";
while (dr.Read())
{
str += "<user><user_id>";
str += dr[0].ToString();
str += "</user_id><user_name>";
str += dr[1].ToString();
str += "</user_name></user>";

}
str += "</Employee>";
StreamWriter sw = File.CreateText("D:\ampl.xml");
sw.WriteLine(str);
sw.Close(); Source: CoolInterview.com

Answered by: Shridhar. A. Bavalatti | Date: 9/30/2008 | Contact Shridhar. A. Bavalatti Contact Shridhar. A. Bavalatti

XML is used basically in JVM(java vertual machine).XML interfaceses between the access of spreadsheet applicacation that is being used in WEB serveses.
In the time of CLR concept it is being used for verify mail services. Source: CoolInterview.com

Answered by: manoj kumar | Date: 1/21/2010 | Contact manoj kumar Contact manoj kumar

da1=new dataadapter("select * from emp",cnn);
da1.fill(dataset1,"emp");
datagid1.datasource=ds;//if u want to display employee details in datagrid

ds.writexml("D:/xmlfile1.xml"); Source: CoolInterview.com

Answered by: sonia | Date: 3/15/2010 | Contact sonia Contact sonia

string str = "";

string s="select * from emp";
SqlCommand cmd = new SqlCommand(s, con);
SqlDataReader dr = cmd.ExecuteReader();
//str += " <?xml version="1.0" encoding="UTF-8"?><Employee>" ;
str += "<Employee>";
while (dr.Read())
{
str += "<user><user_id>";
str += dr[0].ToString();
str += "</user_id><user_name>";
str += dr[1].ToString();
str += "</user_name></user>";

}
str += "</Employee>";
StreamWriter sw = File.CreateText("D:ampl.xml");
sw.WriteLine(str);
sw.Close();

XML is used basically in JVM(java vertual machine).XML interfaceses between the access of spreadsheet applicacation that is being used in WEB serveses.
In the time of CLR concept it is being used for verify mail services.

da1=new dataadapter("select * from emp",cnn);
da1.fill(dataset1,"emp");
datagid1.datasource=ds;//if u want to display employee details in datagrid

ds.writexml("D:/xmlfile1.xml");

Source: CoolInterview.com

Answered by: prashant chourasiya | Date: 4/12/2010 | Contact prashant chourasiya Contact prashant chourasiya

XmlDocument XmlDoc = new XmlDocument();
XmlElement XmlElemt = XmlDoc.CreateElement("", "Team", "");
XmlDoc.AppendChild(XmlElemt);

XmlElement xmlElem1 = XmlDoc.CreateElement("", "Teams", "");

XmlElement xmlElem2 = XmlDoc.CreateElement("", "teamid", "");
XmlText xmltext2 = XmlDoc.CreateTextNode("martin data"));
xmlElem2.AppendChild(xmltext2);






xmlElem1.AppendChild(xmlElem2);

XmlDoc.ChildNodes.Item(0).AppendChild(xmlElem1);


StringWriter sw = new StringWriter();
XmlTextWriter xw = new XmlTextWriter(sw);
xw.Formatting = Formatting.Indented;
XmlDoc.WriteTo(xw);
string doparms = sw.ToString();

StreamWriter sw = new StreamWriter("c:\martin.xml");
sw.WriteLine(doparms);


u will get the o/p as:

<Team>
<Teams>martin data</Teams>
</Team> Source: CoolInterview.com

Answered by: Martin k Abraham | Date: 5/4/2010 | Contact Martin k Abraham Contact Martin k Abraham

create xml file using System.xml Namespace

using System;
using System.Xml;

namespace PavelTsekov
{
class MainClass
{
XmlDocument xmldoc;
XmlNode xmlnode;
XmlElement xmlelem;
XmlElement xmlelem2;
XmlText xmltext;
static void Main(string[] args)
{
MainClass app=new MainClass();
}
public MainClass() //constructor
{
xmldoc=new XmlDocument();
//let's add the XML declaration section
xmlnode=xmldoc.CreateNode(XmlNodeType.XmlDeclaration,"","");
xmldoc.AppendChild(xmlnode);
//let's add the root element
xmlelem=xmldoc.CreateElement("","ROOT","");
xmltext=xmldoc.CreateTextNode("This is the text of the root element");
xmlelem.AppendChild(xmltext);
xmldoc.AppendChild(xmlelem);
//let's add another element (child of the root)
xmlelem2=xmldoc.CreateElement("","SampleElement","");
xmltext=xmldoc.CreateTextNode("The text of the sample element");
xmlelem2.AppendChild(xmltext);
xmldoc.ChildNodes.Item(1).AppendChild(xmlelem2);
//let's try to save the XML document in a file: C:pavel.xml
try
{
xmldoc.Save("c:pavel.xml"); //I've chosen the c: for the resulting file pavel.xml
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.ReadLine();
}
}
}
Source: CoolInterview.com

Answered by: Ganesh | Date: 5/18/2010 | Contact Ganesh Contact Ganesh

dataset.writexml(server.mappath("xml.xmlfile");
dataset.write(dtring name) Source: CoolInterview.com

Answered by: vikas | Date: 6/11/2010 | Contact vikas Contact vikas

dataset.writexml(server.mappath("xml.xmlfile");
dataset.write(dtring name)


Source: CoolInterview.com

Answered by: T.malla reddy | Date: 8/21/2010 | Contact T.malla reddy Contact T.malla reddy


If you have the better answer, then send it to us. We will display your answer after the approval

Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.

Post your answer here

Inform me about updated answers to this question.
Related Questions
View Answer
How can I read .doc document in ASP.Net?

View Answer
Can we run .NET in unix plateform?

View Answer
In .NET Compact Framework, can I free memory explicitly without waiting for garbage collector to free the memory?

View Answer
what i do for load testing in . net application .



View Answer
How many types of assemblies are there , wat are they?

View Answer
What's ArrayList in .Net (VB.Net or C#)
What's the advantageous using ArrayList.




View Answer
How to clear a datagrid on a button click?

View Answer
How will you make .NET programs work in Linux ?

View Answer
Given a server with 4 cpu's, and no databases write a pseudocode to search for the word camera in 100,000 html documents.



View Answer
With respect to security ,which one is the better choice ,.Net or J2EE? Explain.........

View Answer
What Is The Difference Between ViewState and SessionState

View Answer
How different are interface and abstract class in .Net?

View Answer
What is the difference between proc. sent BY VAL and By Ref?
View Answer
Which control cannot be placed in MDI?
View Answer
Which property of the textbox cannot be changed at runtime?
View Answer
What is the maximum size of the textbox?
View Answer
Which controls do not have events?
View Answer
Describe ways of cleaning up objects.
View Answer
What are value types and reference types?
View Answer
What is the Scope of public/private/friend/protected/protected friend ?
View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View All DotNet Interview Questions & Answers - Exam Mode / Learning Mode




India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 1.189453 Seconds