Forum Moderators: open

Message Too Old, No Replies

Using XML in ASP.NET - basics!

How to use XML in a .Net application

         

bhonda

9:12 am on Jul 8, 2005 (gmt 0)

10+ Year Member



Hey,
Another obvious question from me, but I'm getting myself into a mess here, and I just don't understand the basics!
I'm trying to use XML in my ASP.NET document. I've got an XML document with the following content -

<?xml version="1.0" encoding="utf-8"?>
<menulist>
__<menuElement>
____<menuID>0</menuID>
____<menuTitle>Menu0 (0)</menuTitle>
____<adminLevel>0</adminLevel>
____<menuSubElement>
______<menuSubID>1</menuSubID>
______<menuSubTitle>Menu0a</menuSubTitle>
______<adminSubLevel>0</adminSubLevel>
____</menuSubElement>
__</menuElement>
<menuElement>
____.......(etc)
____.......(etc)
</menuElement>
</menulist>

And I've got a xsd file denoting the style of the above.

Now, what I'd really appreciate, is if someone could give me the steps that I need to take in my server-side code (C# prefereably!) so read from this xml file, and store the data in some kind of dataset, or something like it. I've tried googling it, but I get so many different ways to do it, I'm just getting more and more confused! In the end I just want to be able to output the data in the XML file in HTML. Simple!

Hope someone can help,
Thanks in advance,

J

mrMister

2:51 am on Jul 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just want to be able to output the data in the XML file in HTML.

OK, in that case, you're on the wrong track.

You're thinking old school...

read data in one format ->
parse data ->
output data in another format.

You can still do that, but its complicated.

What you want to do is transform the document from one form of XML to another (HTML). Well, strictly speaking HTML is SGML, not XML, but that's close enough :-)

In order to do that, you need to have a read up on XSL (EXtensible Stylesheet Language), and in particular, XSLT (XSL Transformations).

Google should be able to help you out there.

kona

2:00 pm on Jul 11, 2005 (gmt 0)

10+ Year Member



Indeed, the easiest way to do this is using XSLT.
If you do a search in msdn.microsoft.com you'll find lots of useful stuff, like this:
[msdn.microsoft.com...]

bhonda

2:44 pm on Jul 11, 2005 (gmt 0)

10+ Year Member



Cheers guys - that's ace!
Sorry about the bad terminology in my question - I'm glad you figured out what I meant though!
Ta,
J