Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / November 2005

Tip: Looking for answers? Try searching our database.

Inherit from XmlDocument?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gustaf - 28 Nov 2005 16:12 GMT
I have a class that contains a certain kind of XML document. The input
file is *not* an XmlDocument, but when loaded, I want it to work like
the XmlDocument class, like:

MyDocument doc = new MyDocument();
doc.Load("input.txt");   // doc is now an XmlDocument
// Query or modify the XmlDocument as usual
doc.Save("output.xml");  // doc saved using XmlDocument.Save();

That is, the input file is not XML, and the Load() method is obviously
not the same, but otherwise the MyDocument class is a copy of
XmlDocument. Can someone please show me what the MyDocument class shall
look like to inherit from XmlDocument? I never did anything like that
before. Not that I don't want to *extend* XmlDocument with my own Load()
method. I want to *replace* all Load() methods with my own.

Gustaf
Pascal Schmitt - 28 Nov 2005 17:30 GMT
Hello!

> That is, the input file is not XML, and the Load() method is obviously
> not the same, but otherwise the MyDocument class is a copy of
> XmlDocument. Can someone please show me what the MyDocument class shall
> look like to inherit from XmlDocument? I never did anything like that
> before. Not that I don't want to *extend* XmlDocument with my own Load()
> method. I want to *replace* all Load() methods with my own.

There is an easier way: inherit from XmlReader. There are overloads for
the XmlDocument.Load, XslTransform.Load and XpathDocument.Load-Methods
that allow you to specify an own XmlReader. Thus you will gain more
flexibility - and it's easier to write it because you only have to parse
the tokens contained in the file and not create the DOM-Tree yourself.

Signature

Pascal Schmitt


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.