XmlTextWriter Problem

B

babylon

I have an XML tag that may contain optional child element:
i.e.
<mytag myattribute="abc">
<othertag>
...
</othertag>
</mytag>
or just
<mytag myattribute="abc"></mytag>
however, if i do
WriteStartElement("mytag");
WriteAttributeString("myattribute", "abc");
WriteEndElement(); // mytag
it would become:
<mytag myattribute="abc" />
...
can i specify it to become
<mytag myattribute="abc"></mytag>
??

as when i do
ReadStartElement("mytag")
XXXX
ReadEndElement(); // This will fail if it encounter <mytag myattribute="abc"
/ >

but remember that <mytag> may contain sub elements...
...

please help!
 
A

Andrew Gnenny

Hi,
Use WriteFullEndElement to write closed (empty) elements (like this <mytag
myattribute="abc"/>).
During read, use IsStartElement method and IsEmptyElement property to avoid
ReadEndElement failure.
--
Andrew Gnenny
pulsar2003@/no-spam/email.ru (Please remove /no-spam/ for reply)
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
 
B

babylon

it works!
thx!!

Andrew Gnenny said:
Hi,
Use WriteFullEndElement to write closed (empty) elements (like this <mytag
myattribute="abc"/>).
During read, use IsStartElement method and IsEmptyElement property to avoid
ReadEndElement failure.
--
Andrew Gnenny
pulsar2003@/no-spam/email.ru (Please remove /no-spam/ for reply)
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top