The requested page is not available for the requested platform. You are viewing the content for Default platform.

Extract XML Literal to Resource (VB)

Extracts a selected XML literal to a new or existing resource file. Extracted code is replaced with the appropriate resource extraction statement.


This refactoring encourages XML code reuse, as well as code and data separation.


Available from the context menu or via shortcuts:

  • when the caret is on an XML tag. In this case, this tag and its children will be extracted.
  • when an XML code fragment is selected. In this case, the selected fragment will be extracted.
  • when the caret is on a variable that is being assigned an XML code fragment. In this case, the entire right-side part of the assignment will be extracted.

This refactoring is only available in Visual Studio 2008, in VB code.


Dim MyXElement As XElement = _
        <name>Patrick Hines</name>
        <phone type="home">206-555-0144</phone>
        <phone type="work">425-555-0145</phone>


Dim MyXElement As XElement = _