473,379 Members | 1,201 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Removing self-closing tags in XMLDocument.Save

Hi,

I have a VB.NET (VS2005, .NET 2.0) application producing an XML file which
is then used by a third-party product. It turns out the latter doesn't like
self-closing tags (i.e. it would rather see <CardNo></CardNothan <CardNo
/>).

Is there a simple way to tell the XMLDocument to use the "traditional" way
of showing an empty tag instead of always saving self-closing tags?

Many thanks,

David Cartwright
Jun 4 '07 #1
4 11109
David Cartwright wrote:
I have a VB.NET (VS2005, .NET 2.0) application producing an XML file which
is then used by a third-party product. It turns out the latter doesn't like
self-closing tags (i.e. it would rather see <CardNo></CardNothan <CardNo
/>).

Is there a simple way to tell the XMLDocument to use the "traditional" way
of showing an empty tag instead of always saving self-closing tags?
With XML <CardNo></CardNohas the same semantics as <CardNo/or
<CardNo /so you should rather blame that third party tool to not
conform to the XML specification.

As for trying to change your XML with .NET tools, how exactly do you
create the XML? If you use an XmlWriter then use WriteFullEndElement
<http://msdn2.microsoft.com/en-us/library/system.xml.xmlwriter.writefullendelement.aspx>
as that way you can ensure the <CardNo></CardNosyntax.

If you are using XmlDocument/XmlElement then there is a property IsEmpty
that you can set to false to get the form <CardNo></CardNo>.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 4 '07 #2
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:ua****************@TK2MSFTNGP06.phx.gbl...
With XML <CardNo></CardNohas the same semantics as <CardNo/or <CardNo
/so you should rather blame that third party tool to not conform to the
XML specification.
Yup. But they're so useless that if I ask them to fix their end, it'll be at
least Christmas ... and not necessarily the one in 2007 either.
As for trying to change your XML with .NET tools, how exactly do you
create the XML? If you are using XmlDocument/XmlElement then there is a
property IsEmpty that you can set to false to get the form
<CardNo></CardNo>.
I have a load of node creations looking like:
revXML.DocumentElement.AppendChild(revXML.ImportNo de(tmpNode, True))
.... as what I'm doing is pulling nodes out of an input XML document and then
streaming them out to two others.

David C
Jun 4 '07 #3
David Cartwright wrote:
>As for trying to change your XML with .NET tools, how exactly do you
create the XML? If you are using XmlDocument/XmlElement then there is a
property IsEmpty that you can set to false to get the form
<CardNo></CardNo>.

I have a load of node creations looking like:
revXML.DocumentElement.AppendChild(revXML.ImportNo de(tmpNode, True))
... as what I'm doing is pulling nodes out of an input XML document and then
streaming them out to two others.
Then loop through
foreach (XmlElement element in revXML.SelectNodes("//*[not(node())]"))
and set the IsEmpty property of those XmlElement instances to false.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 4 '07 #4
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Then loop through
foreach (XmlElement element in revXML.SelectNodes("//*[not(node())]"))
and set the IsEmpty property of those XmlElement instances to false.
That's great - thanks so much.

David C
Jun 4 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Brent W. Hughes | last post by:
When doing object-oriented stuff, it bothers me to have to type "self" so many times. I propose that Python allow the programmer to optionally type ".variable" instead of "self.variable" to mean...
16
by: qwweeeit | last post by:
In analysing a very big application (pysol) made of almost 100 sources, I had the need to remove comments. Removing the comments which take all the line is straightforward... Instead for the...
11
by: Steven D'Aprano | last post by:
Suppose I create a class with some methods: py> class C: .... def spam(self, x): .... print "spam " * x .... def ham(self, x): .... print "ham * %s" % x .......
1
by: Ilias Lazaridis | last post by:
I have some python code which looks similar to this: class Car(BaseClass) : manufacturer = factory.string() model = factory.string() modelYear = factory.integer() def __str__(self): return...
2
by: Svenn Bjerkem | last post by:
Hi, I am looking for a bit more elaboration on the problem of deleting elements from a QListsView. I know this is a tricky problem with references, but I have not been able to extract enough...
3
by: Kilicaslan Fatih | last post by:
When I push a button to trigger the code: def runCCCC(self, event): cmd_out = self.A_com() if App.runF != "": os.mkdir('C:\copiedFiles') for item in App.runF: App.beCopied = str(item)...
6
by: Chris Chiasson | last post by:
Hi, After reading and experimenting for a several hours, I have this stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"...
3
by: agupta0318 | last post by:
I am trying unsuccessfully to remove some methods from an instance, based on values passed in to the constructor as in the following example: ...
3
m6s
by: m6s | last post by:
Hello to all, I am having trouble removing an item from list, which the item is a list by itself. <code> for self.line in self.filtered: if self.appid: if self.line <> self.appid: ...
11
by: George Sakkis | last post by:
I have a situation where one class can be customized with several orthogonal options. Currently this is implemented with (multiple) inheritance but this leads to combinatorial explosion of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.