ReSharper Web Help

Code highlighting

ReSharper identifies various problems in XML files, such as invalid attributes, incorrect document structure, etc. For instance, ReSharper warns about unexpected attribute in the XML header:

For more information about ways to find out why the code is highlighted, see Finding Out What is Wrong with Your Code.

Examples of context actions

Convert text to CData
If your text inside a tag has XML symbols, it needs to be converted to CData in order not to break the structure of the document. Luckily, there is an appropriate context action.

After applying the context action, your text is wrapped with [CDATA[]] and you can now use XML symbols.

Remove tag and promote children
If you restructure your XML document and want to remove a level of nesting, use this context action.

After applying the context action, the buttons tag is removed and all its child tags are promoted one level up.

Collapse empty tag
If a tag doesn't contain any children or text, it can be converted to an empty tag. There is a context action for this purpose as well.

After applying the context action, the MiddleName tag is converted to an empty tag.

Examples of quick-fixes

Fix XML processing instruction
If there is some problem with the processing instruction, ReSharper informs you and suggests a quick-fix to solve the problem.

After applying the quick-fix, the processing instruction is fixed according to XML rules.

Delete comment
If there is a comment inside a start tag, ReSharper provides a quick-fix to delete that comment.

After applying the quick-fix the comment is properly deleted.

Insert closing tag
If the document structure is incorrect and there is an unmatched opening tag, use this quick-fix to insert the corresponding closing tag.

After applying this quick-fix the closing id tag is inserted.

Rearrange code

Moving Code Elements is available in XML files. So you can move a tag up or down by pressing Ctrl+Shift+Alt+Up or Ctrl+Shift+Alt+Down. Consider the example below.

The author tag can be moved down or out of its parent tag, or into some other tag.

You can also move any attribute within a tag to the left or to the right.

Place the caret at attribute name and press Ctrl+Shift+Alt+Left or Ctrl+Shift+Alt+Right depending on your goals.


File Structure provides a convenient way of viewing the document structure. You can also navigate to an element inside your document by double-clicking the corresponding node inside File Structure window.

Code cleanup

Code Cleanup is available in XML as well. Thus you are not supposed to organise your code manually, ReSharper will do that for you!

You can apply Code Cleanup to a selected block of code, to the opened file or to a number of files. To learn how to apply Code Cleanup to a desired scope, see Running Code Cleanup.

Code Cleanup provides two default profiles - Full Cleanup and Reformat Code - you can use one of them or create a custom profile.

Full Cleanup vs Reformat Code

Action Full Cleanup Reformat Code

Reformat Code

ReSharper reformats code according to settings configured in ReSharper | Options | Code Editing | XML | Formatting Style.

Consider the example below. Before Code Cleanup:


See Also