hello how ru all,
i have some problem in displaying xml file in asp.net, i successfully create
an xml file but when want to display it through ASP.NET code it throwing
following error. Unexpected XML declaration. The XML declaration must be the first node in
the document, and no white space characters are allowed to appear before it.
Line 2, position 3.
below i'm providing my xml file creating code:
<%@Page Language="VB"%>
<%@ Import Namespace="System.XML"%>
<script runat="server">
Sub page_load()
Dim strCurrentPath As String = Request.PhysicalPath
Dim strXMLPath As String = Left(strCurrentPath,
InStrRev(strCurrentPath, "\")) & "newxmlfile4.rss"
Dim objXMLWriter As XmlTextWriter
objXMLWriter = New XmlTextWriter(strXMLPath, Nothing)
objXMLWriter.Formatting = Formatting.Indented
objXMLWriter.Indentation = 3
objXMLWriter.WriteStartDocument()
objXMLWriter.WriteStartElement("rss")
objXMLWriter.WriteAttributeString("version", "2.0")
objXMLWriter.WriteStartElement("channel")
objXMLWriter.WriteElementString("title", "Latest content from
www.mysite.com")
objXMLWriter.WriteElementString("link", "http://www.mysite.com")
objXMLWriter.WriteElementString("description", "Get the latest news
from www.mysite.com")
objXMLWriter.WriteElementString("copyright", "© www.mysite.com")
objXMLWriter.WriteElementString("webMaster", "we*******@mysite.com")
objXMLWriter.WriteEndElement()
objXMLWriter.WriteEndElement()
objXMLWriter.Flush()
End Sub
</script>
And follwing is my xml file displaying code :
<%@ Import Namespace="System.XML"%>
<script language=VB runat=SERVER>
Sub Page_Load()
Dim reader As New
XmlTextReader("F:\ASAD\xmlfiles\newxmlfile4.rss")
Dim xml_doc As New XmlDocument()
xml_doc.Load(reader)
fetchXML.Document = xml_doc
</script>
<asp:xml id="fetchXML" runat="server"
TransformSource="RSSReader.xsl"></asp:xml>
pls review on it and tell me where is the problem thanks. 1 1324
Just save the file you generate once, and look at it in a text editor... see
what it looks like.
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"asad" wrote: hello how ru all,
i have some problem in displaying xml file in asp.net, i successfully create an xml file but when want to display it through ASP.NET code it throwing following error.
Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 2, position 3.
below i'm providing my xml file creating code: <%@Page Language="VB"%> <%@ Import Namespace="System.XML"%> <script runat="server"> Sub page_load() Dim strCurrentPath As String = Request.PhysicalPath Dim strXMLPath As String = Left(strCurrentPath, InStrRev(strCurrentPath, "\")) & "newxmlfile4.rss" Dim objXMLWriter As XmlTextWriter objXMLWriter = New XmlTextWriter(strXMLPath, Nothing) objXMLWriter.Formatting = Formatting.Indented objXMLWriter.Indentation = 3 objXMLWriter.WriteStartDocument() objXMLWriter.WriteStartElement("rss") objXMLWriter.WriteAttributeString("version", "2.0") objXMLWriter.WriteStartElement("channel") objXMLWriter.WriteElementString("title", "Latest content from www.mysite.com") objXMLWriter.WriteElementString("link", "http://www.mysite.com") objXMLWriter.WriteElementString("description", "Get the latest news from www.mysite.com") objXMLWriter.WriteElementString("copyright", "© www.mysite.com") objXMLWriter.WriteElementString("webMaster", "we*******@mysite.com") objXMLWriter.WriteEndElement() objXMLWriter.WriteEndElement() objXMLWriter.Flush() End Sub </script>
And follwing is my xml file displaying code :
<%@ Import Namespace="System.XML"%>
<script language=VB runat=SERVER> Sub Page_Load() Dim reader As New XmlTextReader("F:\ASAD\xmlfiles\newxmlfile4.rss") Dim xml_doc As New XmlDocument()
xml_doc.Load(reader) fetchXML.Document = xml_doc </script>
<asp:xml id="fetchXML" runat="server" TransformSource="RSSReader.xsl"></asp:xml>
pls review on it and tell me where is the problem thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John |
last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to
able to load all 5000 pictures and view 50 per page using
mysql_data_seek(). I would like to know what are the advantages and...
|
by: matt |
last post by:
I have compiled some code, some written by me, some compiled from
various sources online, and basically i've got a very simple flat file
photo gallery. An upload form, to upload the photos and give...
|
by: Hans-Joachim Widmaier |
last post by:
Hi all.
Handling files is an extremely frequent task in programming, so most
programming languages have an abstraction of the basic files offered by
the underlying operating system. This is...
|
by: Nathan |
last post by:
I have an aspx page with a data grid, some textboxes, and an update button.
This page also has one html input element with type=file (not inside the data
grid and runat=server).
The update...
|
by: Neil Rossi |
last post by:
I have an issue with a particular ASP page on two web servers. Let's
call these servers Dev1 and Beta1. Both Servers are running IIS 5,
Windows 2000 SP4 with "almost" all of the latest patches.
...
|
by: Droopy |
last post by:
Hi,
I am running an application on 74 PC (1 instance on each PC).
This morning, 2 applications crashes.
There were neither popup windows signaling it nor dump file created.
I only find in the...
|
by: laredotornado |
last post by:
Hi,
I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed
using Apache's apxs and the php library was installed to
/usr/local/php. However, when I set my "error_reporting"...
|
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming.
FYI
Although I have called...
|
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming.
FYI
Although I have called this...
|
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...
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |