title: Read XElement Fragment from xml file to XElement Element
body: <p>I have xml fragment in an xml-File. The fragment has tags with namespace.</p>
  
  <p>How can I read that xml fragment, which represent exactly an XElement element ?</p>
  
  <pre><code>    &lt;node id="n0::n0"&gt;
    &lt;data key="d6"&gt;
      &lt;y:ShapeNode&gt;
        &lt;y:Geometry height="91.44" width="59.49119999999999" x="364.256180835285" y="-698.4404365079365"/&gt;
        &lt;y:Fill color="#FFCC00" transparent="false"/&gt;
        &lt;y:BorderStyle color="#000000" type="line" width="1.0"/&gt;
        &lt;y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="internal" modelPosition="t" textColor="#000000" visible="true" width="48.677734375" x="5.406732812499968" y="4.0"&gt;MELEIN&lt;/y:NodeLabel&gt;
        &lt;y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="custom" textColor="#000000" visible="true" width="27.35546875" x="16.067865624999968" y="20.843814062500087"&gt;8,00&lt;y:LabelModel&gt;
            &lt;y:SmartNodeLabelModel distance="4.0"/&gt;
          &lt;/y:LabelModel&gt;
          &lt;y:ModelParameter&gt;
            &lt;y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="-0.5" nodeRatioX="0.0" nodeRatioY="-0.2720492775317138" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/&gt;
          &lt;/y:ModelParameter&gt;
        &lt;/y:NodeLabel&gt;
        &lt;y:Shape type="rectangle"/&gt;
      &lt;/y:ShapeNode&gt;
    &lt;/data&gt;
  &lt;/node&gt;
  </code></pre>
  
  <p>I tried a lot of different ways the last one nearly comes to the target</p>
  
  <pre><code>        var mngr = new System.Xml.XmlNamespaceManager(new System.Xml.NameTable());
      mngr.AddNamespace(string.Empty, "urn: ignore"); // or proper URL
      mngr.AddNamespace("y", "urn:ignore"); // or proper URL
      var parserContext = new System.Xml.XmlParserContext(null, mngr, null, System.Xml.XmlSpace.None, null);
  
      var txtReader = new System.Xml.XmlTextReader("block.graphml", System.Xml.XmlNodeType.Element, parserContext);
      var ele = XElement.Load(txtReader);
  </code></pre>
  
  <p>but it crashes in the last line with <code>System.InvalidOperationException</code></p>
  
  <p>Is there any easy way to import xml fragment to an existing xelement?
  I would prefer the way <code>XElement.load("block.graphml");</code> This didn't work at all.</p>
  
  <p>Thanks for your tips</p>