Basic XML Introduction Tutorial: Step 1 2 3 4
![]()
|
||||
Locating errors in the xml file | It is quite likely that when you tried to load your file into the XML Notepad that it complained about something. There are several kinds of thing that could have gone wrong, but fixing them should be relatively simple. Here we go through a few of the more common things that could have happened. You should fix up the file in your text editor as you started, and keep on trying to load the file into the XML Notepad until you succeed. |
|||
Case 1: Garbage-IN garbage-out | The XML Notepad will insist that whatever it works on is at least well-formed XML. So if there are any missing brackets, or mistyped tags, then it will complain. Imagine that you have just typed a tag and have missed off the opening or closing 'angle bracket' "<" or ">". Then the program will reward you with a message such as the following: This tells us that if we look at line 4, 18 characters along, something happened that the editor could not interpret as XML. The line and upward pointing arrow in the window then points directly at the problem position. Here we can see that the closing ">" of the </vb> tag has been missed out, leading to an ill-formed XML file. The incorrect XML that produced this is here. If you try and load this into a web browser, or other XML editor, then you will also get an error message! For example, Netscape 7 informs us:: |
|||
Case 2: Unwanted spaces in the middle of tags | In this next case, we get a similar problem: Here the problem that a space has been put in the middle of the </vb> tag. This is again not legal XML. The buggy XML file that produced this is here. |
|||
Case 3: More unwanted space |
This one is very similar. Here we have an unwanted space in the middle of a starting tag rather than an ending one. This does not work either. The buggy XML file responsible is here. |
|||
Case 4: Unbalanced tags | More subtle are cases where we have missed out an opening or closing tag. This can often happen. We either forget to open a necessary tag and go straight on to its content or forget to say when an element should end because we have given another tag instead. We see this in the following error window: The error message here tells us that when the editor got to line 8, character 74, it found a closing tag that had not been opened. Particularly, in this case, that it found an end tag </cl> which had not been opened with a corresponding <cl> tag: all it could find was a starting <s> tag. The file responsible was this one. |
|||
Case 5: More unbalanced tags | The corresponding case where a start tag is missing is reported as follows: That is, in exactly the same way. This is because the editor cannot tell the difference between a tag being left out at the beginning or at the end: the result is very similar in both cases! And, in both cases, the result is that the file is not a proper XML file (this one is here) and must be corrected. |
|||
Successfully loaded? | When your file loads without problems into the XML Notepad, then it will
be showing you something like the following window.
This means that the XML is now proper syntactically correct XML: in XML jargon, the file is said to be well-formed. You can now proceed with the last step. |
|||
Next step | XML Validation... |