Note that there are some explanatory texts on larger screens.

plurals
  1. POXmlTextWriter responds with System.InvalidOperationException during creation of second element
    primarykey
    data
    text
    <p>I am having trouble with XMLTextWriter.WriteStartElement throwing an exception:</p> <pre><code>System.InvalidOperationException </code></pre> <p>when trying to write the second element in my XML document.<br> This error comes back as <a href="http://msdn.microsoft.com/en-us/library/t8t5yhhk.aspx" rel="nofollow noreferrer">"The Writer is closed"</a>. I have not closed it, so I am guessing it has fallen out of scope??<br> I have created a class to write an XML file using XMLTextWriter as an object within my class. Below is the relevant code. I have found one other post on <a href="http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fcodeguru.earthweb.com%2Fforum%2Fshowthread.php%3Ft%3D471773&amp;ei=dq6mSoHvOJKEnQeK_ImxBw&amp;usg=AFQjCNExYpu6Ukw4M0L8zjpFIAjSl6bQCA&amp;sig2=cJUkoPHrCrL6rX92GOQd-g" rel="nofollow noreferrer">codeguru</a> that was never answered with the exact same issue. Any ideas for workarounds or otherwise would be appreciated.</p> <pre><code>Function CreateXML()... Try _listDocument = New XmlTextWriter(_xmlDI.FullName &amp; "\\" &amp; currentFilename, Nothing) CreateHeader() AddTimeDateNode() CreateXML = True Catch xmlErr As XmlException MsgBox("Unable to create temporary file(" &amp; currentFilename &amp; ") that is used to change your whitelist or blacklist. " &amp; _ "More technical information: " &amp; xmlErr.Message, MsgBoxStyle.Critical, "Can't Continue") End Try End Function Function AddListMember(ByVal listType As String, ByVal listItem As String, ByVal action As String) As Boolean _listDocument.WriteStartElement(listItem) &lt;-- CODE THROWS EXCEPTION HERE! _listDocument.WriteAttributeString("listType", listType) _listDocument.WriteAttributeString("action", action) _listDocument.WriteString(listItem) _listDocument.WriteEndElement() _listDocument.WriteWhitespace(Chr(13) &amp; Chr(10) &amp; "\t") Return True End Function 'Sets the XML header Private Function CreateHeader() As Boolean _listDocument.WriteStartDocument(False) _listDocument.WriteWhitespace(Chr(13) &amp; Chr(10)) Return True End Function 'Add Time Date node Private Function AddTimeDateNode() As Boolean _listDocument.WriteStartElement("DateTimeAdded") _listDocument.WriteString(DateTime.Now.ToString) _listDocument.WriteEndElement() _listDocument.WriteWhitespace(Chr(13) &amp; Chr(10)) Return True End Function </code></pre> <p>I am calling these functions after instantiating a dimension from ListXML (the name of my class) with the following code:</p> <pre><code>Dim xmloutput As New ListXML xmloutput.CreateXML() xmloutput.AddListMember(xmloutput.ReturnWhiteList, currentItem.SenderEmailAddress, xmloutput.ReturnAddAction) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload