473,765 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Removing self-closing tags in XMLDocument.Sav e

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 "traditiona l" way
of showing an empty tag instead of always saving self-closing tags?

Many thanks,

David Cartwright
Jun 4 '07 #1
4 11167
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 "traditiona l" 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 WriteFullEndEle ment
<http://msdn2.microsoft .com/en-us/library/system.xml.xmlw riter.writefull endelement.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*******@yaho o.dewrote in message
news:ua******** ********@TK2MSF TNGP06.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.Document Element.AppendC hild(revXML.Imp ortNode(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.Document Element.AppendC hild(revXML.Imp ortNode(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.SelectNo des("//*[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*******@yaho o.dewrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Then loop through
foreach (XmlElement element in revXML.SelectNo des("//*[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
1961
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 the same thing. Of course, the interpreter would have to be more careful about detecting floats that begin with just a period as in ".5". What are your thoughts?
16
2302
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 embedded comments I used the tokenize module. To my surprise the analysed output is different from the input (the last tuple element should exactly replicate the input line) The error comes out in correspondance of a triple string.
11
2295
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 .... py> C().spam(3) spam spam spam
1
1251
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 '%s %s %s' % (self.modelYear, self.manufacturer, self.model)
2
7064
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 knowledge from the documentation to solve a specific problem: In a dialog I have a QListView called referenceList. Entries are added and deleted from this list with buttons addButton and removeButton connected with sockets:
3
3842
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) shutil.copy(App.beCopied,
6
2065
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" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xmlns="http://www.w3.org/2000/xmlns/" xmlns:mathematica="http://www.wolfram.com/XML/" version="1.0">
3
3381
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: #=============================================================== class A(object): def __init__(self, id): self._id = id return
3
11591
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: print RED + " ".join( map ( lambda x:str(x), self.filtered )) + RESET self.filtered.remove( self.line.index(self.line ) ) else: print "F: " + str(self.line)
11
1718
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 subclasses as more orthogonal features are added. Naturally, the decorator pattern comes to mind (not to be confused with the the Python meaning of the term "decorator"). However, there is a twist. In the standard decorator pattern, the decorator...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5277
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.