Hi Peter,
thanks. I have tried my string builder using the Insert statement
but am still getting the same error. What about my current code
is incorrect? it doesn't sound like it matters if i am using
stringbuilder
or xmltextwriter, and i have changed all the appends to inserts. what
am i missing?
thank you.
Dim sbhtml As New System.Text.StringBuilder
sbhtml.Insert(sbhtml.Length, "<?xml version='1.0'
standalone='yes'?>")
//NOTE: I have also tried surrounded the below with <usrers>
</users>
For i As Integer = 0 To counter - 1
sbhtml.Insert(sbhtml.Length, "<user id='")
sbhtml.Insert(sbhtml.Length, i)
sbhtml.Insert(sbhtml.Length, "' siteid='")
sbhtml.Insert(sbhtml.Length, siteid(i))
sbhtml.Insert(sbhtml.Length, "'>")
sbhtml.Insert(sbhtml.Length, "<photolocation>")
sbhtml.Insert(sbhtml.Length, "../uploads/")
sbhtml.Insert(sbhtml.Length, uname(i))
sbhtml.Insert(sbhtml.Length, "/thumbnails/")
sbhtml.Insert(sbhtml.Length, pname(i))
sbhtml.Insert(sbhtml.Length, "</photolocation>")
sbhtml.Insert(sbhtml.Length, "<headline>")
sbhtml.Insert(sbhtml.Length, headline(i))
sbhtml.Insert(sbhtml.Length, "</headline>")
sbhtml.Insert(sbhtml.Length, "<age>")
sbhtml.Insert(sbhtml.Length, CurrentAge(year(i), month(i),
day(i)))
sbhtml.Insert(sbhtml.Length, "</age>")
sbhtml.Insert(sbhtml.Length, "<lastactive>")
If LastActive(dlogin(i)) <= 1 Then
sbhtml.Insert(sbhtml.Length, "24 hours")
End If
If LastActive(dlogin(i)) > 1 And LastActive(dlogin(i)) <= 7
Then
sbhtml.Insert(sbhtml.Length, LastActive(dlogin(i)))
sbhtml.Insert(sbhtml.Length, " days")
End If
If LastActive(dlogin(i)) >= 7 And LastActive(dlogin(i)) <=
14 Then
sbhtml.Insert(sbhtml.Length, "week")
End If
If LastActive(dlogin(i)) > 14 And LastActive(dlogin(i)) <=
31 Then
sbhtml.Insert(sbhtml.Length, "month")
End If
sbhtml.Insert(sbhtml.Length, "</lastactive>")
sbhtml.Insert(sbhtml.Length, "<aboutme>")
sbhtml.Insert(sbhtml.Length, aboutme(i))
sbhtml.Insert(sbhtml.Length, " ...")
sbhtml.Insert(sbhtml.Length, "</aboutme>")
sbhtml.Insert(sbhtml.Length, "</user>")
Next
Context.Response.ContentType = "text/xml"
//NOTE: I have tried both of the following:
Context.Response.Write(sbhtml.Insert(sbhtml.Length,
sbhtml.ToString))
Context.Response.Write(sbhtml.ToString))
Peter said:
pbd22 said:
hi.
i keep getting this error.
as i understand it, my xml isn't formatted correctly.
It's nothing to do with formatting. It's the structure of your document.
Append adds data below the end of a file: this is an error in XML, where
data must be *inserted* (using the correct element type
). At the end
of the file, once the end-tag has occurred, no further elements are
permitted.
///Peter
--
XML FAQ: http://xml.silmaril.ie/
the online errata suggests the standard formatting
to solve this problem:
element
(tab) (tab) element
(tab) (tab) (tab) element /element
(tab) (tab) (tab) element /element
(tab) (tab) /element
/element
i attempted to acheive this by using the below line (the xml is coming
from the server):
stringbuilder.Append(Microsoft.VisualBasic.vbTab)
but, I still get the error.
I have also tried an xml style sheet with style="padding-left:n"
and this doesnt work.
i keep getting that darn error.
when i alert the XML returned from the server, i get all
elements on the left-most position. no formatting. despite the
two solutions above.
i am guessing this comes up a lot. what am i doing wrong?
thanks!