Display XML Data in ASPX

M

Michelle

Hi, I want to display some pretty basic xml data in
a .NET user control that I would like to build for my
site.

I am getting the XML from a URL that has been provided to
me (i.e. http://domain.com/somelink.asp). If I type the
URL into my browser, the xml doc below is displayed. How
can I incorporate the XML into the user control so that I
can display the company name on my web page?

The XML doc looks like this:
<companies>
<company ID="1" Name="ABC Company"/>
<company ID="2" Name="XYZ Company"/>
<companies>

Thanks for your help.
 
G

Guest

Probably the easy way is to load into DataSet using ReadXml method and bind
the DataSet to the user control.
 
G

Guest

Michelle,

Try using the System.Web.UI.WebControls.Xml control. Drop the control onto
your web form or user control and set the "DocumentSource" to the url of your
xml data. Then set the "TransformSource" property to the url of an XSLT file.
When you run your page the Xml control will perform a transformation and
display your xml data. I've written a simple XSLT sample here that you can
test with:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/companies/company">
<table border="1">
<tr>
<td>
<xsl:value-of select="@Name" />
</td>
</tr>
</table>
</xsl:template>

</xsl:stylesheet>

The XSLT transform above will produce an HTML table that displays the
company name on separate rows as shown below:

ABC Company
XYZ Company

HTH,
Jorge
 
M

Michelle

Thanks Jorge, That's what I started working with. The
problem is it seems like the xml web control only allows
document sources relative to the website itself. I am
trying to access http://somesite/getcompanies.asp to
return my xml doc. I get an error:

"Invalid Map Path... A virtual path is expected"

I can't believe I am not able to retrieve an xml document
from another site. Is that true?

-----Original Message-----
Michelle,

Try using the System.Web.UI.WebControls.Xml control. Drop the control onto
your web form or user control and set
the "DocumentSource" to the url of your
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top