XML well-formedness checking in TextMate

I’ve been working with a lot of XML lately and finding out where your document is not well-formed can be a hassle. Imagine having to find an improperly typed closing node in a ten thousand line XML file with thousands of nodes. Talk about your needle and haystack type of situation, right? Well I two tools I use to help me check the well-formedness of XML files: One on Windows and one on Mac OS X. When I’m working in Windows I use EditPad Pro and on the Mac I use TextMate. Here’s how I’ve configured both to help me find those needles:

TextMate:

[step 1] Download and install these two free TextMate plugins:

[step 2] Open your XML file in TextMate and click Window->Show TeXSLMate palette.

[step 3] Select your preferred Validation options or choose none to check well-formedness only, then click the Parse Button. Boom, Done.

EditPad Pro:

[step 1] Download the following zip file:

[step 2] Extract the xmlValid.exe file to any directory on your computer (I chose just the C: drive).

[step 3] In EditPad Pro configure an external tool:

  1. Click Tools->Configure External Tools

On the Definition tab

  1. Click New
  2. Enter a tool name into the Caption field.
  3. In the Command Line field enter: “C:xmlValid.exe” /c  (NOTE: substitute your own path if it isn’t C:)
  4. Check the Any file option for file types this tool applies to.

On the Standard I/O tab:

  1. Select Current File for What to send to the tool’s standard input.
  2. Select Into the message pane for How to capture the tool’s standard output.
  3. Select Combine with output for the How to capture the tool’s standard error.

Click ok.

[step 4] Open an XML file, then click Tools->Whatever you named your Tool to execute a well-formedness check.

NOTE: You will always see the exception below after running the tool. It means your document was checked and is well formed (as long as the line number in the exception is the last line of your document):

Well-formedness exception from 'filename.xml': '->', hexadecimal value 0x1A, is an invalid character. Line xxx, position xxx.

Posted

in

by