Token StartElement in state Epilog would result in an invalid XML document.

Hi,
I'm trying to write out an xml file with the help of xml writer in asp.net.
This is what my document is supposed to look like:
------------------------------
<?xml version="1.0" encoding="utf-8"?>
<menu
pictureWidth="40"
pictureHeight="40"
mouseOverZoomSize="35"
imageSpacing="10"
mouseOverZoomSpeed="25"
mouseOverZoomInfluence="150"
Mouseover_y="-20"
maxScrollSpeed="0"
minScrollX="-10"
maxScrollX="10"
startPos="0"
enRefl="on"
reflSize="0"
reflAlpha="0"
reflDist="0"
brighten="12"
enTt="on"
tooltipType="black"
tooltipPosition="follow"
tooltipOffset_y="-10"
strokeSize="2"
strokeColour="0xffffff"
rollStrokeSize="2"
rollStrokeColour="0x3d95be"
selStrokeSize="2"
selStrokeColour="0x61acc5"
dockDisplay="show"
dockBgrHeight="88"
yoffsetdockbgrmenu="10"
maskWidth="680"
yoffsetdockmenu="0"

></menu>

<rotator
pictureWidth="590"
pictureHeight="300"
blurPower="20"
speed="5"
initialPostion="1"
arrowsDisplay="auto"
textDisplay="show"
autoPlayTimer="100"
topRectangleColour="0x000000"
topRectangeAlpha="60"
bottomRectangleColour="0x000000"
bottomRectangleAlpha="60"
bottomRectangleHeight="55"
></rotator>

<pictures>

<picture>
<thumb>thumbs/1.jpg</thumb>
<item>images/1.png</item>
<description>Rocky Beach</description>
<link>http://www.google.com</link>
<par>_blank</par>
<displayText><![CDATA[<p><font size="18" face="Arial"color="#C6E4FF">HTML Formatted Information Display. Överallt</font></p><font size="12" face="Arial" color="#FFFFFF">It will supports <b>bold</b>, <i>italic</i>, <font color="#61acc4">color</font><font size="12" face="Arial" color="#FFFFFF">, etc. Also support html tags so that it can be formatted in a nice manner.It will of course be multiline and it will resize acording to the size of the inputed text.</font>]]></displayText>
</picture>

<picture>
<thumb>thumbs/test.swf</thumb>
<item>images/2.png</item>
<description>Supports SWF Files</description>
<link>http://www.google.com</link>
<par>_blank</par>
<displayText><![CDATA[<p><font size="18" face="Arial"color="#C6E4FF">Animated SWF File Support</font></p><font size="12" face="Arial" color="#FFFFFF">You can also add animated flash files to the rotator, including the large item view as well as the thumb.</font>]]></displayText>
</picture>

<picture>
<thumb>thumbs/3.jpg</thumb>
<item>test-images/3.jpg</item>
<description>Cagliari at Night</description>
<link>http://www.google.com</link>
<par>_blank</par>
<displayText><![CDATA[<font size="12" face="Arial" color="#FFFFFF">The titles in the other items are all done with <b>html formatting</b>, text can be plain linke this one.</font>]]></displayText>
</picture>

<picture>
<thumb>thumbs/4.jpg</thumb>
<item>test-images/4.jpg</item>
<description>Road in Autumn</description>
<link>http://www.google.com</link>
<par>_blank</par>
<displayText><![CDATA[<p><font size="18" face="Arial"color="#C6E4FF">Autohide, enable/disable elements</font></p><font size="12" face="Arial" color="#FFFFFF">You can set the dock menu, navigational arrows or the description text to <b>autohide</b>, <b>always stay on</b> or <b>disable</b> them. These settings are independent for each element. In this example all of them are set on auto-hide. Very usefull settings that add a lot of flexibility to your project.</font>]]></displayText>
</picture>

<picture>
<thumb>thumbs/5.jpg</thumb>
<item>test-images/5.jpg</item>
<description>Beautiful Flower</description>
<link>http://www.google.com</link>
<par>_blank</par>
<displayText><![CDATA[<p><font size="18" face="Arial"color="#C6E4FF">Autoplay Setting</font></p><font size="12" face="Arial" color="#FFFFFF">You can set the timer delay for the auto play function (autorotate).</font>]]></displayText>
</picture>

<picture>
<thumb>thumbs/6.jpg</thumb>
<item>test-images/6.jpg</item>
<description>Bee @ Work</description>
<link>http://www.google.com</link>
<par>_blank</par>
<displayText><![CDATA[<p><font size="18" face="Arial"color="#C6E4FF">Custom Motion Blur Transitions</font></p><font size="12" face="Arial" color="#FFFFFF">Not your standard motion blur animation here, this is a custom transition effect.<br>Also supports most common special characters like <br><b>ÀàÈèÙùÂâÊêÎîÉéÍíÓóÚúËëÄäÏïÖöÜüÔôÛûÑñÆæÇ猜€¿ß£ê</b></font>]]></displayText>
</picture>

<picture>
<thumb>thumbs/7.jpg</thumb>
<item>test-images/7.jpg</item>
<description>Villasimius Gulf</description>
<link>http://www.google.com</link>
<par>_blank</par>
<displayText><![CDATA[<p><font size="18" face="Arial"color="#C6E4FF">Complex Dock Menu</font></p><font size="12" face="Arial" color="#FFFFFF">The dock menu navigation used in this banner rotator has over 30 stock settings and a few more added specifically for this file, like the _y positioning of the menu. It's extremely customisable.</font>]]></displayText>
</picture>

<picture>
<thumb>thumbs/9.jpg</thumb>
<item>test-images/9.jpg</item>
<description>Pilot Boat</description>
<link>http://www.google.com</link>
<par>_blank</par>
<displayText><![CDATA[<p><font size="18" face="Arial"color="#C6E4FF">Color and Alpha XML Settings</font></p><font size="12" face="Arial" color="#FFFFFF">You can also customize the color and transparency of the top text background and bottom dock menu background to suit your theme. You can also set the height of the bottom reclangle.</font>]]></displayText>
</picture>

<picture>
<thumb>thumbs/8.jpg</thumb>
<item>test-images/8.jpg</item>
<description>Tunnel in the Alps</description>
<link>http://www.google.com</link>
<par>_blank</par>
<displayText><![CDATA[<p><font size="18" face="Arial"color="#C6E4FF">Easily Resizable</font></p><font size="12" face="Arial" color="#FFFFFF">The banner rotator is easily resizable from xml/embed settings and there's no need for it to be re-compiled if you want the size changed.</font>]]></displayText>
</picture>

<picture>
<thumb>thumbs/2.jpg</thumb>
<item>test-images/2.jpg</item>
<description>Ferryboat</description>
<link>http://www.google.com</link>
<par>_blank</par>
<displayText><![CDATA[<p><font size="18" face="Arial"color="#C6E4FF">Flashvars Support</font></p><font size="12" face="Arial" color="#FFFFFF">For many, this is a very important feature. You can feed the data to the banner rotator directly from the html file through flashvars with no need for a xml file. Or you can specify the name of the xml file and add the content there. Total flexibility.</font>]]></displayText>
</picture>
</pictures>
---------------------------------
This is my code (so far...):
----------------------------
Dim w As New XmlTextWriter(Server.MapPath("~/xml/") & "EventsFlash.xml", Encoding.GetEncoding(28591))
        ' start writing!
        w.Formatting = Formatting.Indented

        w.WriteStartDocument()

        ' Allmänna inställningar --------------------
        w.WriteStartElement("menu")
        w.WriteAttributeString("pictureWidth", "40")
        w.WriteAttributeString("pictureHeight", "40")
        w.WriteAttributeString("mouseOverZoomSize", "35")
        w.WriteAttributeString("imageSpacing", "10")
        w.WriteAttributeString("mouseOverZoomSpeed", "25")
        w.WriteAttributeString("mouseOverZoomInfluence", "150")
        w.WriteAttributeString("Mouseover_y", "-20")
        w.WriteAttributeString("maxScrollSpeed", "0")
        w.WriteAttributeString("minScrollx", "-10")
        w.WriteAttributeString("maxScrollx", "10")
        w.WriteAttributeString("startPos", "0")
        w.WriteAttributeString("enRefl", "on")
        w.WriteAttributeString("reflSize", "0")
        w.WriteAttributeString("reflAlpha", "0")
        w.WriteAttributeString("reflDist", "0")
        w.WriteAttributeString("brighten", "12")
        w.WriteAttributeString("enTt", "on")
        w.WriteAttributeString("tooltipType", "black")
        w.WriteAttributeString("toolTipPosition", "follow")
        w.WriteAttributeString("tooltipOffset_y", "-10")
        w.WriteAttributeString("strokeSize", "2")
        w.WriteAttributeString("strokeColour", "0xffffff")
        w.WriteAttributeString("rollStrokeSize", "2")
        w.WriteAttributeString("rollStrokeColour", "0x3d95be")
        w.WriteAttributeString("selStrokeSize", "2")
        w.WriteAttributeString("selStrokeColour", "0x61acc5")
        w.WriteAttributeString("dockDisplay", "show")
        w.WriteAttributeString("dockBgrHeight", "88")
        w.WriteAttributeString("yoffsetdockbgrmenu", "10")
        w.WriteAttributeString("maskwidth", "680")
        w.WriteAttributeString("yoffsetdockmenu", "0")
        w.WriteEndElement()
        ' -------------------------

        ' rotator ------------------------
        w.WriteStartElement("rotator")
        w.WriteAttributeString("pictureWidth", "590")
        w.WriteAttributeString("pictureHeight", "300")
        w.WriteAttributeString("blurPower", "20")
        w.WriteAttributeString("speed", "5")
        w.WriteAttributeString("initialPosition", "1")
        w.WriteAttributeString("arrowDisplay", "auto")
        w.WriteAttributeString("textDisplay", "show")
        w.WriteAttributeString("autoPlayTimer", "100")
        w.WriteAttributeString("topRectangleColour", "0x000000")
        w.WriteAttributeString("topRectangleAlpha", "60")
        w.WriteAttributeString("bottomRectangleColour", "0x000000")
        w.WriteAttributeString("bottomRectangleAlpha", "60")
        w.WriteAttributeString("bottomRectangleHeight", "55")
        w.WriteEndElement()
        ' -----------------------

        w.WriteEndDocument()
        w.Close()
--------------------------

Everything prints out fine for the first tag ("menu"), but when I add a second tag ("rotator") I get this error:
Token StartElement in state Epilog would result in an invalid XML document.

I'm not sure why. I studied other documents I've done this way and can't find the difference. If someone can help me I would be grateful.

Peter
Peter NordbergIT ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

eguilhermeCommented:
you need to add a root element for all items, eg:


before:
 w.WriteStartElement("menu")

add:

 w.WriteStartElement("root")

and before:
w.WriteEndDocument()

add
w.WriteEndElement()

so that all elements must be inside a main element (root)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Peter NordbergIT ManagerAuthor Commented:
Thanks! That worked!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.