Viewing and Editing an XML Document

Double-clicking a standard XML document will typically open it in Internet Explorer. When XML documents are presented through a browser, they are read-only. To edit XML documents, you must open them with either a text editor such as Notepad or an XML editor.

Although you can use simple text editors, you will find that an XML editor structures your XML documents into reader-friendly trees that make finding and editing content much easier. You can find both free and commercial XML editors online. XML Marker and XML Cook Top are both excellent free editors.

It's generally a good idea to open any new XML documents you encounter with Internet Explorer so they can be checked with Internet Explorer's built-in XML parser. Internet Explorer 5 and above has a built-in DLL that can read XML documents and check for well-formedness. This is akin to the VBA compiling your code and checking for syntax errors. If the XML document you are trying to open is not well formed, the parser will throw an error message. The idea here is that if Internet Explorer cannot open your XML file, you will not be able to use it in Excel.

Every version of Internet Explorer from Internet Explorer 5 on has its version of the built-in MSXML.DDL parser. The MSXML.DLL comes with its own object model called the Document Object Model (DOM). Later, you will learn how to leverage this object model to read and edit data from XML files.

Just for the record, a well-formed document has the following characteristics:

□ There is one root element encapsulating all content in the XML document.

□ All element tags have a start tag and a matching end tag, as in <element></element>.

□ None of the element tags have mismatched cases (such as <Element></element>).

□ All child elements are closed before their parents. For instance, <Parent><Child></Parent> </Child> would cause a parsing error because the child element is closed after the parent element has been closed. The correct sequence would be <Parent><Child></Child></Parent>.

□ All attributes have one value wrapped in either single or double quotes.

Once your XML document has been validated by Internet Explorer, opening with no parsing errors, it is ready to be used.

0 0

Post a comment