Editing XML Files

Technical Articles > Working with XML Files

XML documents consist of elements. Some of these elements contain the document's text, other elements represent the document's structure. Consider the following XML document that contains a list of addresses:

<?xml version="1.0"?>
<?XML:stylesheet type="text/css" href="addresses.css"?>
<!DOCTYPE Addresses SYSTEM "addresses.dtd">
         <Name>Jack Miller</Name>
         <Street>Baker Street</Street>
         <City>New York</City>
         <Name>Tom Baker</Name>
         <Street>Miller Street</Street>
         <City>Los Angeles</City>
         <Name>Bill Taylor</Name>
         <Street>Old Street</Street>

In this example, the elements DocumentHeadline, Name, Street and City contain the document's text, the other elements Addresses, AddressTable and Address are structural elements without any text. After this document has been loaded, a Text Control displays it WYSIWYG with the formatting styles found in the specified CSS file and automatically switches to the XML editor mode. In this mode, text can be inserted or deleted like in any other document. Text selections are possible only inside single XML elements. If a user tries to select more than one element, the selection is expanded to its maximum, which is the complete text of the single element.

Like in tables, the TAB (Shift TAB) key can be used to select the complete text of the next (previous) element. Clipboard operations are possible as in any other document, but if text is inserted from another document, it is inserted without any formatting attributes.

Because XML documents do not contain formatting attributes they can be changed only via formatting styles. Formatting via the Button Bar changes the attributes of the current style. Formatting via formatting functions is disabled in XML documents. To change formatting attributes either the built-in style dialog boxes available through the TextControl.FormattingStylesDialog method or the InlineStyle and the ParagraphStyle collections can be used. To make these changes permanent, the new attributes must explicitly be saved in the CSS file.