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:
ReSharper_by_Language__XML__Code_Highlighting_01
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.
ReSharper_by_Language__XML__Context_Actions__convert_text_01
After applying the context action, your text is wrapped with [CDATA[]] and you can now use XML symbols.
ReSharper_by_Language__XML__Context_Actions__convert_text_02

Remove tag and promote children
If you restructure your XML document and want to remove a level of nesting, use this context action.
ReSharper_by_Language__XML__Context_Actions__remove_and_promote_01
After applying the context action, the buttons tag is removed and all its child tags are promoted one level up.
ReSharper_by_Language__XML__Context_Actions__remove_and_promote_02

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.
ReSharper_by_Language__XML__Context_Actions__collapse_empty_tag_01
After applying the context action, the MiddleName tag is converted to an empty tag.
ReSharper_by_Language__XML__Context_Actions__collapse_empty_tag_02

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.
ReSharper_by_Language__XML__Quick-Fixes__fix_processing_instruction_01
After applying the quick-fix, the processing instruction is fixed according to XML rules.
ReSharper_by_Language__XML__Quick-Fixes__fix_processing_instruction_02

Delete comment
If there is a comment inside a start tag, ReSharper provides a quick-fix to delete that comment.
ReSharper_by_Language__XML__Quick-Fixes__delete_comment_01
After applying the quick-fix the comment is properly deleted.
ReSharper_by_Language__XML__Quick-Fixes__delete_comment_02

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.
ReSharper_by_Language__XML__Quick-Fixes__insert_closing_tag_01
After applying this quick-fix the closing id tag is inserted.
ReSharper_by_Language__XML__Quick-Fixes__insert_closing_tag_02

Rearrange code

Moving Code Elements is available in XML files. So you can move a tag up or down by pressing Ctrl+Shift+Alt+UpCtrl+Shift+Alt+Up or Ctrl+Shift+Alt+DownCtrl+Shift+Alt+Down. Consider the example below.
Coding_Assistance__Moving_Code_Elements__move_xml_tags_01
The author tag can be moved down or out of its parent tag, or into some other tag.
Coding_Assistance__Moving_Code_Elements__move_xml_tags_02

You can also move any attribute within a tag to the left or to the right.
Coding_Assistance__Moving_Code_Elements__move_xml_tags_03
Place the caret at attribute name and press Ctrl+Shift+Alt+LeftCtrl+Shift+Alt+Left or Ctrl+Shift+Alt+RightCtrl+Shift+Alt+Right depending on your goals.
Coding_Assistance__Moving_Code_Elements__move_xml_tags_04

Navigation

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.
ReSharper_by_Language__XML__File_Structure

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

feature_available

feature_available

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

Consider the example below. Before Code Cleanup:
ReSharper_by_Language__XML__Code_Cleanup_01
After:
ReSharper_by_Language__XML__Code_Cleanup_02