473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Xmlfile into Datalist

Reading xmlfile into a datalist or reapeter countrol specially in .net2003
and also how do we read it in .net2005
Mar 8 '07 #1
7 1280
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
Mar 8 '07 #2
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....
Mar 9 '07 #3
what error, are you getting and when are you getting?while populating dataset ? or after populating it?
Mar 9 '07 #4
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

<?xml version="1.0" encoding="utf-8" ?>
<countries>
<country name="india">
<capital>Delhi</capital>
</country>
<country name="SriLanka">
<capital>Colombo</capital>
</country>
<country name="nepal">
<capital>khatmandu</capital>
</country>
</countries>


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)

I am a begineer in .net.

so kindly help me in doing this,

thank you.
Mar 9 '07 #5
the error it displayes
-----------------------------------------------
Could not find file "C:\WINDOWS\system32\countryCapital.xml".
Mar 9 '07 #6
will u please explain breafly
how should be the xml schema.
for the following .xml file...


<?xml version="1.0" encoding="utf-8" ?>
<countries>
<country name="india">
<capital>Delhi</capital>
</country>
<country name="SriLanka">
<capital>Colombo</capital>
</country>
<country name="nepal">
<capital>khatmandu</capital>
</country>
</countries>
thank you
Mar 9 '07 #7
will u please explain breafly
how should be the xml schema.
for the following .xml file...


<?xml version="1.0" encoding="utf-8" ?>
<countries>
<country name="india">
<capital>Delhi</capital>
</country>
<country name="SriLanka">
<capital>Colombo</capital>
</country>
<country name="nepal">
<capital>khatmandu</capital>
</country>
</countries>
thank you
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(string xmlFileName,string xmlSchemaFile)
{
XmlDataDocument xmlFile = new XmlDataDocument();
DataSet ds = new DataSet();
try
{
xmlFile.DataSet.ReadXmlSchema(xmlSchemaFile);
XmlTextReader TrainReader = new XmlTextReader(xmlFileName);
TrainReader.MoveToContent();
xmlFile.Load(TrainReader);
ds = xmlFile.DataSet;
}
catch (Exception e)
{
ds.Dispose();
MessageBox.Show(this,e.Message,"Error");
}
return ds;
}


Let me know if you have any problem.
Mar 13 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Niklas Lagergren | last post by:
Hi, I'll try to explain. I'm now using C# and I have an xmlfile that contains users and information about them, this xmlfile can be read and changed from many threads in my application, as many...
3
by: Flare | last post by:
H I have a dll lib wich contains a static method to read and return a result from a xmlfile. But is possible that this dll could be called at the same time from muliple threads. Is this a...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
6
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
0
by: Les Caudle | last post by:
I have a menu system composed of a DataList nested inside a DataList. The outer DataList has it's DataSource (composed of a DataSet with two tables linked by a CategoryPagesRelation Relation) set...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.