Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading XML Files 1

Status
Not open for further replies.

WiseNewbie

Programmer
Jan 9, 2004
45
AU
Hi,

I'm new to ASP.NET and C#. I'm trying to complete a website written for a friend, but he has one major requirement. That all the news items be stored in a XML File instead of a database. How do I use XML in ASP.NET?

I'd be formatting the XML Document like:

<News>
<NewsItem>
<Heading>Aliens are in Uranus</heading>
<Date>12/12/2012</Date>
<Description>Yadda yadda yadda</descriptioN>
</newsitem>
</news>

and so on, i'm also looking to sort those items by date(ascending order) but only have 4 items on the left hand menus - i'll cache these - but I'm stumped on how to actually use the XML side of .NET. I dislike DataGrids for this situation, i need to be able to loop around and write a custom bit of HTML to display the contents. I have no idea what XSL is either unfortunetly.

Thanks:)
 
You can easily read the XML file into a dataset, then manipulate the dataset as desired...

<%@ Import Namespace=&quot;System.Data&quot; %>

<Script runat=&quot;server&quot;>

Sub Page_Load
Dim dstMenu As DataSet
dstMenu = New DataSet()
dstMenu.ReadXml(MapPath(&quot;Menu.xml&quot;))
...
...
End Sub

XSL (eXtensible Sytelsheet Language) enables you to perform transformations on the contents of an XML document. .NET classes support W3C XSL specs.

You can do a little research on the net and find several examples of implimenting XLS stylesheets in conjunction with reading XML files. This may be the route to go since XSL is designed to format and transform an XML document into a nice looking HTML document.

XSL also carries out format conversion which enables it to be shared between different applications.

XSL sytlesheets can be applied through Xml control, or XSL Transform class.

You might visit the W3C web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top