I have a problem with a code for a meta language. It takes the string with the code in the target language and then saves it, with XDocument
in an html document. My question is this: When I was using it in a test program, I gave an error "Can not add non-blank space characters to content.
"and I can not solve it, does anyone help me? code:
//Obtém o código.
public XDocument ReturnCode(string code)
{
//"Divide" ele.
string[] parts = code.Trim().Split();
//Cria 3 variaveis que representam a tag body, a tag head e a outra que vai "alterná-las".
string body = "";
string head = "";
int BodyHead = 0;
foreach (string c in parts)
{
//Se "c" for igual a ";", alterna entre "body" e "head"
if (c == ";")
{
BodyHead = 1;
}
if (BodyHead == 0 && c != "{" && c != ";")
{
head += c;
}
else if (BodyHead > 0 && c != "{" && c != ";")
{
body += c;
}
}
//Cria e retorna o código.
return new XDocument("html",//<html></html> tags.
new XElement("head", head.Trim()),//<body>[content]</body> tags.
new XElement("body", body.Trim())//<head><[content]</body> tags.
);
}