C# – how to fetch result from “for xml path”

c++sqlxml

Now I have a stored procedure (SQL server) which will return a XML from "for xml path" statement. I've try to read the response with ExecuteXmlReader and ExecuteReader, but I got nothing.
I've google a while but still can't find how to extract the return value, or, how to retrive the return value. Should I use ExecuteXmlReader? or something else?
Thanks.

con.Open();
        string result = "";
        XmlReader tmp = cmd.ExecuteXmlReader();

        while (tmp.Read())
        {
            string s = tmp.Value;
        }

        return result;

Best Solution

The ReadOuterXml method returns the current node and all of it's children if positioned on an element or attribute node, otherwise it returns an empty string. You can read the nodes attributes by index or name.

XmlReader tmp = cmd.ExecuteXmlReader();
tmp.Read();
while (!tmp.EOF) {
    string name = tmp["AttributeName"];
    string s = tmp.ReadOuterXml();
}