As a part of StyleCop, I am examining method-documentation. See the following:
/// <summary>
/// Copies the node.
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <param name="originalClassName">Name of the original class.</param>
/// <param name="newClassName">New name of the class.</param>
/// <param name="nodeName">Name of the node.</param>
/// <param name="ID">The identifier.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException">doc</exception>
My goal is to get the returnvalue out of this block.
The text is given to me as an entire string. I tried parsing it into an XDocument to retrieve the return-element, but was not able to because of the lack of a root-element.
Is there any way for me to retrieve the return-value stored inside <returns></returns>
tag? (Note that it is empty here by design, because that is actually what I want to discover; if it is empty.
I know this seems a bit dirty, but I'd do:
string xml = "<root>" + text + "</root>";
XDocument doc = XDocument.Parse(xml);
XElement returns = doc.Root.Element("returns");
if (returns != null)
{
string returnsDescription = returns.Value;
...
}