473,513 Members | 2,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlDocument Inheritance problem

I have created a class which inherits from XmlDocument.
It works as I expected.
If I use Visual Studio, and type a <carriage return> after
"inherits XmlDocument", VS adds three method overrides.
These seem to make sense, but then the class doesn't
behave as I intended, or as it did if I typed in the data
myself. See example below.

Imports System.xml
Module Module1

Sub Main()
Dim doc1 As New SimpleInheritance
Dim doc2 As New VisualStudioInheritance

End Sub

End Module
Public Class SimpleInheritance
Inherits XmlDocument

Public Sub New()
MyBase.New()
LoadXml("<tag>text</tag>")
Console.WriteLine("SimpleInheritance: " &
OuterXml & "End of text")
End Sub
End Class
Public Class VisualStudioInheritance
Inherits XmlDocument
Public Sub New()
MyBase.New()
LoadXml("<tag>text</tag>")
Console.WriteLine("VisualStudioInheritance: " &
OuterXml & "End of text")

End Sub
Public Overrides Function CloneNode(ByVal deep As
Boolean) As System.Xml.XmlNode

End Function

Public Overrides Sub WriteContentTo(ByVal w As
System.Xml.XmlWriter)

End Sub

Public Overrides Sub WriteTo(ByVal w As
System.Xml.XmlWriter)

End Sub
End Class
I cann't see why the three methods have the effect that
they do. Sure it's obvious, but help would be
appreciated........
Thanks

Robin Hay

Nov 20 '05 #1
1 1631
Having overridden those methods, when the XmlDocument needs to call them for
some reason, nothing will happen. You should be able to just delete those
methods, but if you HAVE to have them, simply add
MyBase.FunctionName(params) (Example: MyBase.CloneNode(w)) to the last line
of the method. Calling the MyBase version of the function tells VB to "do
whatever the function is supposed to do" in addition to what your override
does. I'm rambling, but I hope this makes sense.
"Robin Hay" <ha****@btconnect.com> wrote in message
news:02****************************@phx.gbl...
I have created a class which inherits from XmlDocument.
It works as I expected.
If I use Visual Studio, and type a <carriage return> after
"inherits XmlDocument", VS adds three method overrides.
These seem to make sense, but then the class doesn't
behave as I intended, or as it did if I typed in the data
myself. See example below.

Imports System.xml
Module Module1

Sub Main()
Dim doc1 As New SimpleInheritance
Dim doc2 As New VisualStudioInheritance

End Sub

End Module
Public Class SimpleInheritance
Inherits XmlDocument

Public Sub New()
MyBase.New()
LoadXml("<tag>text</tag>")
Console.WriteLine("SimpleInheritance: " &
OuterXml & "End of text")
End Sub
End Class
Public Class VisualStudioInheritance
Inherits XmlDocument
Public Sub New()
MyBase.New()
LoadXml("<tag>text</tag>")
Console.WriteLine("VisualStudioInheritance: " &
OuterXml & "End of text")

End Sub
Public Overrides Function CloneNode(ByVal deep As
Boolean) As System.Xml.XmlNode

End Function

Public Overrides Sub WriteContentTo(ByVal w As
System.Xml.XmlWriter)

End Sub

Public Overrides Sub WriteTo(ByVal w As
System.Xml.XmlWriter)

End Sub
End Class
I cann't see why the three methods have the effect that
they do. Sure it's obvious, but help would be
appreciated........
Thanks

Robin Hay

Nov 20 '05 #2

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

Similar topics

2
8699
by: Ayende Rahien | last post by:
Serious problem I'm using Chris Lovett's SgmlReader class SgmlReader sr = new SgmlReader(); XmlDocument xdoc = new XmlDocument(); sr.DocType = "HTML"; sr.InputStream = new System.IO.StringReader(node.InnerText); xdoc.Load(sr);
4
4831
by: Robert Rossney | last post by:
I'm trying to send and receive XmlDocument objects using the System.Messaging.dll functions. The code I've written follows, as best I can tell, the methodology used in the sample code for the XmlMessageFormatter class. But it isn't working -- specifically, receiving isn't working. What am I doing wrong here? I begin by creating a...
1
6800
by: Shawn | last post by:
Hi. I'm using a FileStream (instead of just the path to the xml file) to load an XmlDocument. I'm doing this because I need to be able to prevent other processes to update the file I'm working on. The problem is that I'm getting multiple processing instructions and multiple root elements in my xml file when I use a FileStream. Here is an...
7
4879
by: SQLScott | last post by:
I have a Web Service in which I am trying to pass an XMLDocument as a parameter to one of the methods. I would like to use the XMLTextReader to read the XML but I am getting the following error: Value of type System.xml.xmldocument cannot be converted to System.IO.textreader. I would think this is possible to do. Code snippet is below:
14
12879
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at all obvious in VBA which lacks inheritance. I'm trying the explanation again now. I often find cases where a limited form of inheritance would...
3
1855
by: Mungo Jerrie | last post by:
Hi there :-) I have some problems with the same instance of my xmldocument across 3 different classes. See code below: class one { protected static XmlDocument doc = new XmlDocument(); public static XmlDocument getXmlDocument(){
1
327
by: itsme | last post by:
Hello, How can one copy an XmlDocument "A" into another XmlDocument "B" When I say "copy", I mean to replace the XmlDocument "A" completely by the XmlDocument "B". I am trying to use cloneNode method of the XmlDocument but somehow I am getting multiple copies of the same node.
1
3615
by: Joe Monnin | last post by:
I have a web service that takes an XmlDocument as a parameter, performs some processing on it, and saves it to a database. The web service signature looks similar to this: public void SaveDocument(XmlDocument doc) { //Method logic omitted } The web service worked great in .net 1.1, but upon upgrading to .net 2.0 IIS
3
3878
by: Stephen Ward | last post by:
I have a simple little project open a xml file change a few nodes save the file, no big deal. The problem is that the doctype is getting modified when I save the file. So it looks like this: <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> But when I save it : <!DOCTYPE plist PUBLIC...
0
7269
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...
0
7177
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...
1
7123
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...
0
7542
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...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3248
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...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1611
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
1
811
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.