Reading xmlfile into a datalist or reapeter countrol specially in .net2003
and also how do we read it in .net2005
why dont you try to load the xmlfile into a dataset and then, adding that dataset as a DataSource for Datalist of repeater control?
FYI, to load the xmlfile into a dataset, you should have schema file that has the schema information of that xmlfile
Thank You for your Response, But i already tried it as
First i had an xml.file
i took an object of a dataset
an then i read the xml file into dataset using readxml method of the dataset
and then i set the datalist datasource to the dataset
but it is not working.
plz help me....
Hi
the thing is i don't have database in my system so i tried with xml to fill the dtagrid with that xmlfile,
first i added an xml file and i have writen something like as followes
I want to populate my datagrid with this data....
it is asking me something about xsd,xslt
to read xml file do we need to go with xsd & xslt .. what is the relation among those(.xml,.xsd ,.xslt)
You need to create xsd file for the xml file that you have.
in VS.NET environment, open the XML file and right click on any part of the data. You can see "Create Schema" Option there. Click on that and VS will create an xsd file for you. Only thing you need to do is change the second line of your xml file as
<countries xmlns="http://tempuri.org/testFile1.xsd">
Following method can be used for retriving a Dataset from an XML file
private DataSet getXmlDataSet(s tring xmlFileName,str ing xmlSchemaFile)
{
XmlDataDocument xmlFile = new XmlDataDocument ();
DataSet ds = new DataSet();
try
{
xmlFile.DataSet .ReadXmlSchema( xmlSchemaFile);
XmlTextReader TrainReader = new XmlTextReader(x mlFileName);
TrainReader.Mov eToContent();
xmlFile.Load(Tr ainReader);
ds = xmlFile.DataSet ;
}
catch (Exception e)
{
ds.Dispose();
MessageBox.Show (this,e.Message ,"Error");
}
return ds;
}
Comment