XML Tools Plugin - Can't get Pretty Print feature to work



  • @PeterJones
    Hi Peter, and thanks for your reply.
    I am on a different computer right now, with same version of NP++ and XML Tools installed.
    I just copied the XML code you provided and pasted it in NP++ then selected Plugins --> XML Tools --> Pretty Print and it worked fine, then I toggled several times between Linearize and Pretty Print and it all went smooth.
    I will do the same on my work computer and further advise (my expectation is that it won’t work as I think something is corrupted in the NP++ installation on that PC).
    Michele



  • I just tried the Pretty Print and Linearize features on the initial computer again, but before telling about the outcome I want to explain a bit more about the background.

    Right after posting my help request, I realized that as a side effect of my several attempts to Pretty Print an XML file I was working on, two non-XML files that were open at the same time were heavily messed up.

    The first one is a massive generic text file with a lot of work notes about all my tasks, and in this one a lot of crazy indentations were added (this is what I noticed, not sure if other changes were done).
    The second one is a Progress 4GL source file, and in this one all code indentations disappeared.

    Now I have just reproduced that same situation (three files open: notes file, Progress source file and XML file) and:

    • XML Tools features worked (never seen this happen before)
      BUT
    • Right after any Pretty Print or Linearize operation, NP++ will switch me to another of the two files and mark all three files (not only the XML one) as changed.

    So it looks like something is definitely corrupted in my NP++ installation, not sure how to solve this, of course I will try reinstalling the app but I am concerned that the issue might be in the registry and if that’s the case I am afraid the issue will be still there.



  • @Michael-Vincent
    Thanks Michael for your reply.
    Please see my previous post, actually it is not about syntax errors in the XML I was using, as I have successfully tried Pretty Print on the same file I was trying initially.



  • Final update: all issues look to have disappeared after I uninstalled NP++ then installed it again.
    XML Tools is now working fine, and using its features on one specific XML file won’t affect other files that are open at the same time.
    Before reinstalling the whole NP++, I tried reinstalling the XML Tools plugin and that did not solve the issues.



  • @PeterJones So how to add Pretty print as a plug in, find unclosed tags and close them in multiple files of a folder?



  • @Michael-Vincent @guy038 @PeterJones All files have a .html or .htm extension in that folder



  • @Ramanand-Jhingade said in XML Tools Plugin - Can't get Pretty Print feature to work:

    @PeterJones So how to add Pretty print as a plug in, … in multiple files of a folder?

    It doesn’t work that way. XML Tools Pretty Print just works on the active document.

    If you want to change many XML files, I recommend searching the internet for command-line XML “pretty print” tools.

    Or you could use the PythonScript plugin and write a Python-based script that will open each file from the folder (or each file matching ‘.htm’ or ‘.html’, per your update) into Notepad++'s active window, then use the PythonScript notepad.runPluginCommand() to run the XML Tools Pretty Print on the file, then save and close the file. It’s pretty easy to do.

    find unclosed tags and close them

    It really doesn’t work that way. The XML Tools “Pretty Print” just moves the tags to different lines so that it’s more readable by a human; it doesn’t “fix” missing closing tags and such.

    I am not an XMLTools expert, but I don’t think it has a function/feature that will fix broken XML/HTML in an existing file; if another user of XML Tools knows differently, feel free to jump in here.

    There have been other discussions in the forum which show how to do regular expressions that in limited circumstances can add in missing closing tags. You could search for those and study previous answers given. But no regular expression is going to be able to close such tags under generic circumstances with lots of tag nesting.

    If you’ve got a very specific HTML/XML error, like “I have a bunch of <span> tags that are missing their closing tag, and I need to add a </span> either at the end of the current line, or before the next closing tag of any sort”, then that very-directed specific problem is probably fixable by regular expression (as previous posts that you’ll have to search for will explain). Once you have stated a concrete, specific problem that is solvable, then use the resources that you’ve been pointed to multiple times, and try to solve the problem yourself. If you run into difficulty, then start a discussion specific to that question rather than hijacking another unrelated discussion, show what you tried, give examples of the data you have vs. the data you want, and explain why you thought what you tried would work.

    Please understand that Notepad++ (or any text editor or coding language) isn’t a magic bullet that will just “fix” all your problems for you; you will have to put in some effort to fix these things.

    it looks like you’ve been handed a website’s HTML that’s in a severe mess right now, and have been thrown into the deep end beyond your abilities to fix it. That sucks for you. But you’re going to have to learn, and put in the effort of trying to fix it yourself, first. Please understand that the Notepad++ Community Forum isn’t a free code-writing-and-data-manipulation service; we’ve already given you lots of help… but we cannot just fix this whole mess for you; paying a contractor may cost significant money to fix all the problems you have, but you cannot just treat us like a free contractor who can do your work for you… and it really feels like that’s how you view us. We will answer specific questions about the features, limitations, and workarounds in Notepad++, but we cannot just fix all your bad HTML data for you.



  • @PeterJones Sorry, I had no intention of abusing this community (I did not intend to make you a free Contractor but I did need solutions). I did find something to check each file individually at http://www.tormus.com/tools/div_checker which finds unclosed <div> tags



  • For the records:

    @PeterJones said in XML Tools Plugin - Can't get Pretty Print feature to work:

    XML Tools Pretty Print just works on the active document.

    (Un-)Fortunately not, maybe that was the issue this thread is about. The XML Tools plugin has the ability to apply pretty-printing on all files currently opened via a menu option:

    0114d853-f21c-4e05-9999-65f42cd62fd5-grafik.png

    @PeterJones said in XML Tools Plugin - Can't get Pretty Print feature to work:

    find unclosed tags and close them

    It really doesn’t work that way.

    Of course, XML Tools plugin does not fix unclosed tags but it is able to find them by its Check XML syntax now feature:

    e341bd50-4db3-4888-bb41-ec61a7d6e40d-grafik.png

    As you can see in the screenshot above it is also able to syntax-check an XML file while a user is editing it.

    The Validate now and Enable auto-validation features do not check the syntax but validate the XML document against an XSD schema file.



  • Some final words just to summarize: my issue with XML Tools Pretty Print feature not working (and making damage in other opened files) was caused by some corrupted NP++ components, probably due to some update installation glitch.
    After a clean reinstallation of NP++ everything was ok, I have been using XML Tools since then and it is doing great.


Log in to reply