XML Parser and Editor

Parsing XML can be a time-consuming task, especially when you have a huge set of data or many nested nodes. UltraEdit’s XML manager allows you to navigate through the XML tree, search, move nodes up and down, copy or cut nodes, and even duplicate with ease. In this power tip, We’ll take a look at how to use the XML manager in UltraEdit.

How to Parse and Edit an XML File

Open the XML manager

If the XML manager isn’t already visible, you can open by checking the XML manager option in the Layout tab of the ribbon.

If the active file is a valid XML file, the XML manager will parse the file and display its various nodes and information.

Navigating in the XML manager

The XML manager provides multiple methods of navigating between nodes.

Expand/Collapse Nodes
At the most basic level, you can expand and collapse nodes in the XML manager using the + and - icons.

Search
You’ll notice a text field at the top of the XML manager. You can type something here and hit Enter to search for this string in the XML data. The XML manager will jump to the first node that matches the search string. If there are multiple matches, you can hit Enter again to jump to the next occurrence.

Navigating within the File
Of course, the XML manager parses the XML file, but you can also navigate throughout the file by double-clicking on the elements in the XML manager.

Editing XML files with the XML manager

You can can also use the XML manager to modify and edit your XML files.

Select the Node
If you wish to select the actual text of the entire node, hold the Shift key and double click it in the XML manager. This will highlight the entire node in the editor. You can begin typing to overwrite it or delete it.

Drag-and-drop
You can reposition the XML nodes in your XML file by clicking on them in the XML manager and dragging them to a new location.

The node will be moved to the position after the node on which you drop it.

There are several other options available in the XML manager’s right-click menu. To see the options, simply right-click in the XML manager. You will see the following options:

Up / Down
Moves selected node down in the XML tree, actually modifying the XML file.

Copy / Select
Copies or selects the text of the XML node.

Copy XPath
Copies the XPath of the selected XML node to the clipboard. In the above screenshot, the XPath /datasets/dataset would be copied to the clipboard.

Format document
Reformats (pretty prints) the active XML file, adding appropriate line breaks and indentation.

Parse document
Parses (or re-parses) the XML structure and data of the active file, which populates the XML manager.

Cut
Cuts the text of the selected XML node from the file to the clipboard.

Replace with clipboard
Replaces the selected node with the contents of the clipboard.

Paste before
Pastes the node in the clipboard before the active node.

Paste after
Pastes the node in the clipboard after the active node.

Duplicate
Duplicates the selected node below the active node in the document tree.

Other tips

Adding support for other file types
The XML manager parses any file that is syntax highlighted as XML. UltraEdit assumes a file is XML and highlights it as such if either 1) it has an “.xml” file extension, or 2) the first line of the file contains an XML identifier like <?xml version='1.0' ?>. If your file has neither of these, then you’ll need to either add the XML identifier or add the file’s extension to the “File extensions” definition in the XML wordfile. A tutorial on how to do this is available in this power tip.

If you don’t want the file type to permanently parse as XML, you can temporarily view the file with XML syntax highlighting by selecting that language type in the status bar drop down

Correcting errors in XML files
The XML manager expects a valid and well-formed XML document in order to parse the file. If you have any errors in your XML, the XML manager will indicate what those are and their location. You double click on the error to jump to it in the file.

Configure the XML manager
You can configure some of the behavior of the XML manager by clicking on Settings in the Advanced tab then navigating to the XML manager branch.