Page 2 of 2 FirstFirst 12
Results 41 to 53 of 53

Thread: Indenting XML properly using MSXML4

  1. #41
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Indenting XML properly using MSXML4

    Quote Originally Posted by eyeRmonkey
    Yeah, I was having problems with the picturebox also, thats weird.

    I fixed it myself though, I needed to specify the whole path to the XML and XSL files for some reason. No biggy though. After that it worked perfectly. Thanks a million Marty.

    I think I might package this into a module and post it into the codebank (fully crediting its original author ).
    Sure. I was thinking about doing that myself.

  2. #42

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: Indenting XML properly using MSXML4

    How does this look for a CodeBank submission? Should I add real error trapping inside the module? I've never done a real CodeBank sumbission before. Any other suggestions?
    Attached Files Attached Files
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  3. #43

  4. #44

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: Indenting XML properly using MSXML4

    I hard coded it so you can easily add it to any project without having to keep track of the module and the .xsl. I see that as saving time and effort. That way you can just drop in the module to any project that uses XML and you don't have to think about it.

    I switched it MSXML2 just in the example project because more people are likely to have MSXML2 than MSXML4 (I just got MSXML4 a few days ago). You can use the module with any version of MSXML.

    Does that explain it better? Other than those, are there any changes I should make?
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  5. #45
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Indenting XML properly using MSXML4

    Here is what I'd do. The changes I made were minor and you should feel free to accept or reject any of them. You should of course remove all the commented-out code.
    Attached Files Attached Files

  6. #46
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Re: Indenting XML properly using MSXML4

    Martin,

    I found a situation. Your method of indentation works all fine and dandy when it is just elements and attributes. When there is text in element area, for some reason, it does not indent properly the first element.

    I attached a file so you can see the result. Notice, if I take out the text, everything is fine.
    Attached Files Attached Files
    I'll Be Back!

    T-1000

    Microsoft .Net 2005
    Microsoft Visual Basic 6
    Prefer using API

  7. #47

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: Indenting XML properly using MSXML4

    I forgot to link this thread back to my CodeBank submission. Here is the module that I created after Martin's help in this thread:

    http://www.vbforums.com/showthread.php?t=368314




    Liquid Metal,
    Try that version of the code and see if you get the same results.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  8. #48
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Re: Indenting XML properly using MSXML4

    Still does the same thing. It will indent all except for the first child node under the root if the root has text.
    I'll Be Back!

    T-1000

    Microsoft .Net 2005
    Microsoft Visual Basic 6
    Prefer using API

  9. #49

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: Indenting XML properly using MSXML4

    I don't know what to say. I feel inclined to blame the MSXML isntead of my/Marty's code because all the code does is apply an XSL transformation and specify that we want to indent. Maybe Marty would have some insight into this problem?
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  10. #50
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Indenting XML properly using MSXML4

    Quote Originally Posted by eyeRmonkey
    I don't know what to say. I feel inclined to blame the MSXML isntead of my/Marty's code because all the code does is apply an XSL transformation and specify that we want to indent. Maybe Marty would have some insight into this problem?
    No, sorry, I don't.

  11. #51
    Frenzied Member
    Join Date
    Apr 2003
    Location
    The Future - Skynet
    Posts
    1,157

    Re: Indenting XML properly using MSXML4

    Thank You Martin and Monkey! It is not a big deal but just thought it was a bit strange. I didn't think it was your/Martin's code but was just puzzle how it were transformed.
    I'll Be Back!

    T-1000

    Microsoft .Net 2005
    Microsoft Visual Basic 6
    Prefer using API

  12. #52
    Addicted Member adamm83's Avatar
    Join Date
    Oct 2005
    Location
    Toronto, ON, Canada
    Posts
    180

    Re: Indenting XML properly using MSXML4

    I'm just curious. Your code reads the XML and formats it properly then prints it into a textbox, but how can i get it to write back to the XML file properly formatted?
    adamm
    ACM Designs

    Codebank:
    RegOpen - Open registry keys in Regedit quick & easily


    "A man who tries to catch two rabbits at the same time will catch neither."

  13. #53
    Lively Member
    Join Date
    Jul 2008
    Posts
    73

    Re: Indenting XML properly using MSXML4

    i aslo do need to indent the xml file created thr' msxml4.0 with vb code not for loos but for finding the location of error om xml validation against xsd.
    i do get the eror correctly but its detection in my xml file is difficult as it takes the whole created document as one line document & hence throws the eror no in different columns but samle line , line 1
    but techincally on broswwwers it appears orrect , node by node with proper indention
    if i redo the xml documnent manually in any ediotr i get the proper location
    how do i rectify it thr; code

Page 2 of 2 FirstFirst 12

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