[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

XmlTextWriter end tag question

Posted on 2006-05-18
5
Medium Priority
?
593 Views
Last Modified: 2013-11-19
Hello,

I am working on an app that uses the XmlTextWriter class to create an XML doc.  The problem is that my xml doc will have several nodes like this:

<folders>
      <folder>
           <foldername />
           <folderID />
      <folder
      ...
<folders />

This is all fine, when the properties of the folder (name, ID) are empty, I want the xml tag to look like it does above  '<foldername />'.  But if there are no folders in the folder collection, I want it to be written like this:

<folders></folders>, and I can only seem to get it to write it like this <folders />.

Does anyone know how to force this seperate ending tag?

Thanks
0
Comment
Question by:Tim_Heldberg
  • 3
  • 2
5 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 16711776
Hi Tim_Heldberg,

not sure how the code looks like,  but when adding elements you could look into the WriteStartElement and WriteEndElement to use them explicitly when there are no values for a folders node

hope this helps a bit
bruintje
0
 
LVL 4

Author Comment

by:Tim_Heldberg
ID: 16712053
I have been using the calls to WriteStart and WriteEnd, that is what is actually what is producing what I have shown above.  Here is a code snip.

            jobScript.WriteStartElement(DescriptorNameNodeName);
            jobScript.WriteString(descriptor.Name);
            jobScript.WriteEndElement();

The same thing is being produced whether name has a value or an empty string.
0
 
LVL 44

Accepted Solution

by:
bruintje earned 2000 total points
ID: 16712117
0
 
LVL 4

Author Comment

by:Tim_Heldberg
ID: 16712297
Thanks for the help.  I had actually been trying that call and I thought I was getting the same result.  The thing is that it was actually working right, but when I was viewing the xml in internet explorer, it was collapsing the empty nodes into the single tag.
0
 
LVL 44

Expert Comment

by:bruintje
ID: 16712350
ah so you already was using the correct approach, maybe you can bill microsoft for some wasted time :)

thanks for the grade
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question