473,385 Members | 1,267 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,385 software developers and data experts.

ASP.NET XML control prepends raw XML stream to XSL transform output

Okay, this one's been bugging me for a few hours and I can't figure out
what to do about it. I've been working on a little project for work
that will take an RSS feed, extract certain items from it, and display
them on a webpage. Simple enough, right? Quite, except for the fact
that one of the items that needs to be displayed is a date, which is
stored in the format yyyy-MM-dd hh:mm:ss.f, and they want it displayed
nicely as MMMM dd yyyy or something like that. Easy enough, right?

So I wrote a little C# to convert the date to something nice. Here's my
code in full:

protected Xml xml;

private void Page_Load(object sender, System.EventArgs e)
{
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.Document.NameTable);
nsmgr.AddNamespace("event","http://www.acs.rutgers.edu:8888/calendar/FeaturedEventRSS#");

XmlNodeList
XmlNodeList nodeList =
xml.Document.SelectNodes("//*/event:startDateTime",nsmgr);
for(int i = 0; i < nodeList.Count; i++)
{
nodeList[i].InnerText =
XmlConvert.ToDateTime(nodeList[i].InnerText.Replace("
","T").Substring(0,19)).ToString("MMMM dd yyyy h:mm:ss");
}
}

The method that does the actual work isn't the prettiest thing ever,
but it gets the job done. However, for whatever reason, this code
snippet causes something very unusual to happen. The XML control on the
..aspx page will perform the transform as requested, but it prepends the
entire contents of the XML file in question, but without tags and
showing the effects of the code snippet above. This indicates to me
that for some reason the XML file is being duplicated and processed
twice, first without the XSL transform and then with.

What's odd about the whole thing is that I also put together a sample
identical to the one above, but without the XmlNamespaceManager, to
test on an XML file without namespaces (the file that I'm being
provided with for the actual implementation does have namespaces, as
you can see above), and it does NOT exhibit that behavior there. Could
the namespace manager somehow be causing this? If so, can anyone shed
some light on this, or at least suggest a workaround?
--
Edmund Rhudy

Nov 12 '05 #1
0 1829

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sandy | last post by:
Hi, I have some data stored in my internal data structure. I am writing this data in an xml file and invoking xalan on this file to perform some transformation. After the transformation I want...
1
by: Chris Pels | last post by:
I am sending the XML output of an XslTranform to a StringWriter and the <xml> header has an encoding type of "utf-16" which IE 6 does not like/support. How do I get the encoding value in the output...
3
by: Christopher Ambler | last post by:
This has to be a FAQ, but I can't seem to find the answer anywhere! I have an application that consumes a web service that returns me a string full of XML. I also have an XSLT for outputting the...
2
by: Stan | last post by:
I could not find the answers for these two questions about in Xml server control 1. Is it possible for control to keep its ViewState? Even if I set EnableViewState = true the control does not seem...
2
by: Dave | last post by:
Hi I have a Xml Web Server control on my page <asp:Xml id=Xml1 runat="server" EnableViewState="True"></asp:Xml> I'm doing a transform as follows System.Xml.XmlDocument doc = new...
2
by: mpriem | last post by:
Hi, I am trying to create a webapplication which reads a Xml Document and dynamically creates tables containing the values. The Xml Document is created by a windows service I programmed. So if I...
11
by: Webbert | last post by:
I am trying to display XML in a WebBrowser Control. I receive a data feed of XML and am trying to inject it into the control. I have not been successful in doing so. The only solution I have...
1
by: pax82 | last post by:
hi, sorry for my english but i don't speak good english. in this web service i send 2 data stream(xml and xsl file) and i would like to return a xslt trasform-file byte array (now i return string...
7
by: mathieu | last post by:
Hi there, I am trying to rewrite this very slow function (due to AFAIK the extra copy): void DoAction(std::istream &is, std::ostream &os) { uint16_t c; while( is.read((char*)&c,2) )
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.