Unable to convert string to XElement

260 views Asked by At

I am creating a xml file, but am unable to convert the string in the tag <Nb>

 <Header>
 <Body>
 <Nb>13</Nb>    
 </Body>
 </Header>

How do I convert it to an XElement item? I want to avoid using Linq, XmlDoc if possible...

1

There are 1 answers

1
Irelia On BEST ANSWER

Try using the XElement.Parse like so

private XElement XmlNumber()
{    
   XElement nb = XElement.Parse("<Header><Body><Nb>13</Nb></Body></Header>");

   return nb;    
}

Examples here: How to convert from string to XElement object