Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

How can i separate tags in a xml file

I have a code that create an xml file but when this code receive an empty string aperars like this  <Label /> and i need this structure <Label></Label> how can i get this? I have this code:
xWriter.WriteStartElement("Label")
xWriter.WriteString("")
xWriter.WriteFullEndElement()
0
albloe1975
Asked:
albloe1975
1 Solution
 
planoczCommented:
Has to be more like this....
With xWriter
      .WriteStartDocument()
     .WriteStartElement("MyMainTag")
      WriteElementString("Label", "")
     .WriteEndElement()
    .Flush()
   .Close()
End With

0
 
wausaufsCommented:
The suggested solution does not work for what I need. For a business requirement, I need an element like this: <ProviderID></ProviderID>. Following the suggested solution, I tried:
            writer.WriteStartElement("PID");
            writer.WriteElementString("ProviderID", String.Empty);
            writer.WriteFullEndElement();

This gives me either an extra tag I don't want:
<PID>
  <ProviderID />
</PID>

Every other solution I've tried like the following gives me <ProviderID />.
            writer.WriteStartElement("ProviderID");
            writer.WriteString(String.Empty);
            writer.WriteFullEndElement();

It appears that WriteEndElement() does not provide the single functionality it is designed to provide.

Does anyone know how to accomplish this?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now