Reputation: 458
C#
noticia.Add(new XElement("Imagem", <BR>));
i need :
<Imagem><BR></Imagem>
and not:
<Imagem><BR></Imagem>
thanks all
Upvotes: 1
Views: 2085
Reputation: 458
I realy use classes:
I recive from on class the string:
string OutClass = "xpto. <BR>";
and i use the XElement()
in another class.
Upvotes: 0
Reputation: 22064
Just do this
noticia.Add(new XElement("Imagem", new XElement("BR")));
However that will give you an extra /
which you NEED or it's not valid XML.
<Imagem><BR/></Imagem>
The other options is using CDATA
noticia.Add(new XElement("Imagem", new XCData("<BR>")));
Which will get you
<Imagem><![CDATA[<BR>]]></Imagem>
Just generating <Imagem><BR></Imagem>
is impossible as it's not valid xml.
EDIT: If you have the string with other text, in a variable, your only option is CDATA, like this
var OutClass = "xpto. <BR>";
noticia.Add(new XElement("Imagem", new XCData(OutClass)));
Which results in
<Imagem><![CDATA[xpto. <BR>]]></Imagem>
Upvotes: 5