Results 1 to 8 of 8

Thread: VB.NET: XmlDocument

  1. #1

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    VB.NET: XmlDocument

    Hi

    Recently, i am dealing stuff with Xml..

    there was one part where i use the XmlDocument..

    I am a bit confuse because if i wanted to use the XmlDocument class, i must create a Xml file to load into the document... or else there would be error.

    Can the file be create directly by using the XmlDocument instead of using XmlTextWriter to create first and then load it into the XmlDocument..

    Is there any method to deal with it...

    Thanks

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    I really didn't understand what you're trying to deal with over here, but here are a few links for working with the XMLDocument Class:

    http://msdn.microsoft.com/library/de...ssavetopic.asp

    http://support.microsoft.com/default...301233&SD=MSDN

  3. #3

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230
    What i means is that could it be possible to write and save a xml file first using XmlDocument Class before using the Load() to load any xml file...

    what if i did not have any Xml file to load and want to create first..

    the examples you show always load a xml file first before editing the content and save again...

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    OK, I see what you're getting at. I only know how to create an XML file using XMLTextWriter, but then there should be no problem when loading such a file.

    It's quite possible that the problem lies in how you're writing the file.

    Got code?

  5. #5

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230
    What you mean is to create a Xml file using XmlTextWriter first...

    and later on don't use the XmlTextWriter method...

    instead use XmlDocument class to load the Xml file (the file that used XmlTextWriter to write eariler on)

    From there onwards, use XmlDocument to edit any stuff and save again...

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Yes.

    You can work like that. You can create your XML file in the writer, load with XMLDocument. No problems.

    After reading your first post and last post, I'm a little confused. It's as if you've made an assumption and are asking about it, but it seemed to me that you had already tried it and were facing problems.

    And in the last post, you seem to be talking to yourself.


  7. #7

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230
    ok...

    yeah...i have already try it..

    I am not talking to myself...but to guess and summarize what you say in the previous message that you sent just now...

    And also combine my idea to the suggestion you give earlier on..

    Is that the only solution to do that ?...

    I means to create the file first with XmlTextWriter before loading using XmlDocument...
    Last edited by toytoy; Sep 20th, 2004 at 02:46 AM.

  8. #8
    Member
    Join Date
    Sep 2004
    Location
    Oklahoma City, OK
    Posts
    36
    Depending on the complexity of the document you're attempting to create, you could also go with a completely DOM-oriented approach, meaning that you create objects and place them in the document hierarchy programmatically.

    Code:
    Dim x As XmlDocument = New XmlDocument()
    x.AppendChild(x.CreateElement("root"))
    ...
    x.Save("[filespec]")
    T

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width