innerxml

Best way to get InnerXml of an XElement?

What's the best way to get the contents of the mixed "body" element in the code below? The element might contain either XHTML or text, but I just want its contents in string form. The XmlElement type has the InnerXml property which is exactly what I'm after. The code as written almost does what I want, but includes the surrounding <bo...

PHP SimpleXML get innerXML

I need to get the HTML contents of answer in this bit of XML: <qa> <question>Who are you?</question> <answer>Who who, <strong>who who</strong>, <em>me</em></answer> </qa> So I want to get the string "Who who, <strong>who who</strong>, <em>me</em>". If I have the answer as a SimpleXMLElement, I can call asXML() to get "<answer>Who w...

Setting InnerXml for XmlDocument causes missing End-Tag

XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateElement("Foo")); doc.DocumentElement.InnerXml = "Test"; StringBuilder result = new StringBuilder(); doc.WriteContentTo(XmlWriter.Create(result)); At the end, result is: <Foo>Test that means the end element is missing. Why is ...