I'm trying to display an XML Web Response using the ASP.Net form GridView. I'm new to the .NET framework so I'm struggling with some of the particulars.
I'm developing a search engine so the XML response is the result of a search for a particular phrase or word. This is a sample of the XML response
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">8</int>
<lst name="params">
<str name="qf">recordkey</str>
<str name="df">text</str>
<str name="echoParams">all</str>
<str name="indent">true</str>
<str name="wt">xml</str>
<str name="q">*:*</str>
</lst>
</lst>
<result name="response" numFound="281" start="0">
<doc>
<str name="Date Created">2014-10-30</str>
<str name="Facility">*****</str>
<str name="Author">*********</str>
<str name="Source System ID">*******</str>
<str name="Data Source">************</str>
<str name="Title">ENGINEERING INITIATION</str>
<long name="_version_">1504985395557826560</long>
</doc>
<doc>
<str name="Date Created">2011-09-30</str>
<str name="Facility">*********</str>
<str name="Author">************</str>
<str name="Source System ID">***</str>
<str name="Data Source">***************</str>
<str name="Title">USE OF REGISTERED....</str>
<long name="_version_">1504985395859816448</long>
</doc>
<doc>.....
...........
I blocked out some of the content but you get the idea.
Once I get the response I use a StreamReader to read the xml and put it into a XMLDocument.
XmlDocument myXMLDocument = new XmlDocument();
GridView1.DataSource = myXMLDocument;
StreamReader myXMLReader = new StreamReader(response.GetResponseStream());
ds.ReadXml(myXMLReader);
GridView1.DataSource = ds.Tables["str"];
GridView1.DataBind();
After that I load it into a DataSet and bind the table "str" to the Gridview which produces this result
name str_Text lst_Id doc_Id
qf recordkey 1
df text 1
echoParams all 1
indent true 1
wt xml 1
q *fire* 1
Date Created 2014-10-30 0
Facility ***** 0
Author **** 0
Source System ID *** 0
Data Source **** 0
Title **** 0
Date Created 2011-09-30 1
Facility **** 1
Author **** 1
Source System ID **** 1
Data Source ***** 1
Title USE OF REGISTERED... 1
Date Created 2011-11-03 2
Facility **** 2
Author ***** 2
Source System ID *** 2
Data Source ******* 2
Title REQUEST... 2
Now, the problem, I'm having problems organizing the content in the gridview. It only recognizes the column names as field names. I want to be able to to organize the information into a more typical search format such as
Date Created - "Followed by the title here"
Author Name
But I can't manipulate those things because they aren't seen as fields. So my overarching question. How do I use the gridview so I can manipulate based on attributes instead of the column names in the dataset? Do I have to bind it to the grid differently? Is there a sort that needs to be coded (Like by doc ID)? I don't really care the method I just need to be able to do it.