Hello!
How to retrieve XML data & display on the page in the table?
Yes, I will be using asp to retrieve the data from the DB.
Regards,
Hello!
How to retrieve XML data & display on the page in the table?
Yes, I will be using asp to retrieve the data from the DB.
Regards,
Hey I have this example for you!
I hope this helps you!Code:<table border="1"> <tr> <td><b>Title</b></td> <td><b>Grade</b></td> </tr> <% xmlStr = "<QoE>" & _ "<Qual><Title>BTEC%20first%20diploma/GNVQ%20Inter%20ICT</Title><Grade>Pass</Grade> </Qual>" & _ "<Qual><Title>Communication%20(KS)</Title><Grade>L2</Grade></Qual>" & _ "<Qual><Title>AoN</Title><Grade>L1</Grade></Qual>" & _ "</QoE>" Set objXML = Server.CreateObject("Microsoft.XMLDOM") objXML.loadXML(xmlStr) Set oNodes = objXML.selectNodes("//QoE/*") For Each oChild In oNodes Response.Write "<tr><td>" & oChild.childNodes(0).text & "</td><td>" & oChild.childNodes(1).text & "</td></tr>" Next %> </table>
A simple example of using the managed classes for getting XML output from the SQL Server database is given below. This code uses the XML AUTO mode for generating the XML data.
static string xmlstr = "Provider=SQLOLEDB;Server=(local);database=Orders;";
public static void SampleSqlXml ()
{
Stream objStr = Console.OpenStandardOutput();
SqlXmlCommand sqlcmd = new SqlXmlCommand(xmlstr);
sqlcmd.Root = "Orders";
sqlcmd.CommandType = SqlXmlCommandType.Sql;
sqlcmd.CommandText = "SELECT OrderNo, OrderValue FROM Orders FOR XML AUTO";
strm = sqlcmd.ExecuteToStream(objStr);
objStr.Close();
}
For more information and samples on the managed classes that are used for retrieving data in XML format from SQL Server you can refer to the MSDN documentation.
Bookmarks