display xml file in browser with asp.net - asp.net

This may be simple, although i'm having some trouble finding a solution.
i create a sitemap for my website in an xml file.i display content of xml file in aspx file.
but i want display xmlfile not in aspx.
when i use response.redirect("sitemap.xml"),it shows tree but i want to show only all content in sequential not in tree.
like this:
content of xmlfile:
<t><t1 p="s1"></t1><t2 p="s2"></t2></t>
but i want address bar=sitemap.xml and show like this:
p=s1p=s2 .....
any idea?

Some browsers will respect XSL declarations at the top of xml files. If you have such a declaration at the top of your xml file like this:
<?xml-stylesheet type="text/xsl" href="YourTransform.xsl"?>
It will apply the transform specified allowing you to output the xml however you want. However, support is not universal.

Related

Display FORMATTED XML

I am retrieving an XML document from a web service (UPS actually), and I can pull the information I need from the XML, but I can't get the XML to display in the XML format. I can get it to display in a label and literal, but its all ran together. The nodes aren't displaying. The nodes display in a text box control, but it still runs together (no brks)
Any idea how to take the XML document that i get from the service and display it just like it would if you open up an XML doc in IE?
Thanks
BTW... i have search all day for this and the only thing i could find is if i was displaying a static file, which i'm not. I also tried doing the stringbuilder/stringwriter, but no luck. I'm still pretty new at this stuff so i could be missing something.
HELP... PLEASE!
Try encompassing the XML in the
<pre>... your xml</pre>
tags.

XSLT - unmapped fields at bottom of html

I have an XML document which references a XSL file for the output of HTML.
In the XSL file I have put in various "<xsl:value-of select="fieldname" />" tags referencing items in my XML File.
However for the items I have not mapped they just appear as a long string at the bottom of the html page?
Do I really need to omit all my xml data items not referenced in the XSL file for them to go away or is there a trick to this or a bug in my XSL file?
j
This is result of the XSLT Processing Model.
XSLT uses its *built-in templates` if a node should be processed and no template in the XSLT code is matching it. The built-in template that matches a text node copies it.
Solution:
Add this template that overrides the XSLT built-in template for text nodes:
<xsl:template match="text()"/>
This causes any text node not matched by a more specific template in the code (and not copied with xsl:copy-of or xsl:value-of) to be ignored ("deleted").

make aspx page display sml document

Im trying to make an aspx page display as xml for an rss feed
the output looks like its formed ok when i view the source:
<?xml version="1.0" encoding="ISO-8859-1" ?><rss version="2.0"><channel><title>phil</title><link>http://www.mysite.co.uk/blog.aspx</link><description>phils blog</description><item><title>Test Blog</title><link>
http://www.phil.co.uk/blog/test-blog.aspx</link><description>test description</description><pubDate>2011-10-21T14:19:28</pubDate><guid> http://www.phil.co.uk/blog/test-blog.aspx</guid></item></channel></rss>
But when i view the page in chrome it just shows the text from the nodes and not a visual of the xml structure. What do i need to do?
You could use the Google Chrome Tree Extension.
I will suggest you to Use EXtensible Stylesheet Language (XSTL)
You can display xml directly on browser without using any ASPX page. It is used to styling of your xml.
Let me know, if you have any concern.

Is is possible to show XML attributes when using an external CSS style sheet?

I'd like to display some XML in the browser, but add some custom color styling, etc., to certain attributes of tags. I am able to get an essentially blank external sheet recognized:
<?xml-stylesheet href="/css/testresult.css"?>
But this seems to have the effect of making the browser display the XML as if it were HTML, i.e. it only displays tag content text and not attributes. Is there any way to get the "raw" XML display view, but with just a few tweaks to styling?
Using Firefox if that's relevant.
The thing is, when Firefox displays XML files, it uses it's own parser, so I don't see how that could be influenced by your stylesheet, as the only function of the parser is to display XML in a readable way.
Maybe you can use XSLT you do what you need, but that would require some additional work.
http://www.w3schools.com/xml/xml_xsl.asp
Have yet to see any indication it's possible.

How to display XSL-transformed XML in ASP.NET page?

So far all the XML / XSLT I've worked with takes an XML document and transforms it to a standalone HTML webpage using an XSLT file.
In my web application, I'm using a web service to retrieve the XML document, which I need to render and make human-readable, and then insert that formatted content into a content placeholder in my master page.
The easiest way would be to append the XSLT to the retrieved XML file and link that to the content placeholder, but something tells me I can't just do that.
I took a look at these Stack Overflow pages, but they just want to render the straight XML whereas I want a transformed XML. Also, I need to be able to put it into my master page template.
This article shows how:
http://www.codeproject.com/Articles/37868/Beginners-Introduction-To-XSL-Transform-Rendering-XML-Data-using-XSL-Get-HTML-output.aspx
even if the spelling is as bad as mine...
Added
And here's another link that shows how, perhaps a bit more simply
http://www.aspfree.com/c/a/XML/Applying-XSLT-to-XML-Using-ASP.NET/2/

Resources