Ok, here's what I did and it seems to get pretty close without too much
effort.
1. go to msdn to get the various schema, there are 4:
Response
http://msdn.microsoft.com/library/en-us/rssdk/html/rsxsdResponse.asp
Response.Document
http://msdn.microsoft.com/library/en-us/rssdk/html/rsxsdResponseDocument.asp
Types
http://msdn.microsoft.com/library/en-us/rssdk/html/rsxsdTypes.asp
You may also need Response Content, Response Form (depending on what your
queries return). eg
http://msdn.microsoft.com/library/en-us/rssdk/html/rsxsdResponseContent.asp
http://msdn.microsoft.com/library/en-us/rssdk/html/rsxsdResponseForm.asp
Save each of these schema to a separate XSD file .
----
2.
modify the Response schema. The Response schema "Results" field is typed as
"anything" (xsd:any). But if you are doing sharepoint searches, it will
likely be a combination of Document, Content, and Form. The sample you
showed me had 2 results, both were documents. Your other queries may return
something else.
In any case I replaced this:
<xsd:complexType name="ResultCollectionType">
<xsd:annotation>
<xsd:documentation>Defines a set of results, in any format
supported.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:any namespace="##other">
<xsd:annotation>
<xsd:documentation>Any element in another namespace. Elements here
will be in any results format supported by the client. Office will support
the Form, Document, and Content results types.</xsd:documentation>
</xsd:annotation>
</xsd:any>
</xsd:choice>
</xsd:complexType>
with this:
<xsd:complexType name="ResultCollectionType">
<xsd:annotation>
<xsd:documentation>Defines a set of results, in any format
supported.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="doc:Document" />
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="content:Content" />
</xsd:choice>
</xsd:complexType>
and saved that doc to Microsoft.Search.Response-Modified.xsd
----
3. generate classes that correspond to this schema using the xsd.exe
utility. here's what I did:
xsd.exe /namespace:sps /c Microsoft.Search.Response-Modified.xsd
Microsoft.Search.Response.Document.xsd Microsoft.Search.Types.xsd
Microsoft.Search.Response.Content.xsd
(the above all on one line)
This produces a source file that has a really really long name. I renamed
it to (ResponsePacket.cs)
----
4.
You can now de-serialize directly from the stream, or from a file as shown
here:
sps.ResponsePacket packet;
string path = "Response-Pretty.xml";
XmlSerializer s1 = new XmlSerializer(typeof(sps.ResponsePacket));
System.IO.FileStream fs = new System.IO.FileStream(path,
System.IO.FileMode.Open);
packet= (sps.ResponsePacket) s1.Deserialize(fs);
----
5. accessing the fields is done like this
System.Console.WriteLine("Response Packet contains {0} Items ",
packet.Response.Length);
for (int i=0; i < packet.Response.Length; i++) {
System.Console.WriteLine("Item {0}: ", i);
System.Console.WriteLine(" Copyright: {0}",
packet.Response[i].Copyright);
System.Console.WriteLine(" Status: {0}",
packet.Response[i].Status);
System.Console.WriteLine(" domain: {0}",
packet.Response[i].domain);
if (packet.Response[i].Range!= null) {
System.Console.WriteLine(" Range: ( {0} items)",
packet.Response[i].Range.Length);
for (int j=0; j < packet.Response[i].Range.Length; j++) {
System.Console.WriteLine(" Item: {0}", j);
System.Console.WriteLine(" StartAt: {0}",
packet.Response[i].Range[j].StartAt);
System.Console.WriteLine(" Count: {0}",
packet.Response[i].Range[j].Count);
System.Console.WriteLine(" TotalAvailable: {0}",
packet.Response[i].Range[j].TotalAvailable);
if (null != packet.Response[i].Range[j].Results) {
System.Console.WriteLine(" Results: ({0} items)",
packet.Response[i].Range[j].Results.Length);
for (int k=0; k < packet.Response[i].Range[j].Results.Length;
k++) {
System.Console.WriteLine(" Item: {0}", k);
if (packet.Response[i].Range[j].Results[k] is sps.Document)
ShowDocument((sps.Document)packet.Response[i].Range[j].Results[k]); //
shows Title, relevance, Date, etc
else if (packet.Response[i].Range[j].Results[k] is
sps.Content)
ShowContent((sps.Content)packet.Response[i].Range[j].Results[k]); //
similar
}
}
}
}
}
----
6.
What you want to do is, I think, bind the list of Documents
(packet.Response[i].Range[j].Results ) to a DataGrid. The problem is that
objects in an array must have public properties if they are to be bound to a
DataGrid. And the generated code for the Document type does not expose
public properties.
See this article
http://msdn.microsoft.com/library/en-us/dnexxml/html/xml01202003.asp , about
30% down, for a brief discussion for how to work around this.
-Dino
> One other thing: The goal is not to use a Dataset per se; what I am
> using this for is to locate documents by the URL; using the consolidated
[quoted text clipped - 8 lines]
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!
Daniel Cazzulino [MVP XML] - 28 Jun 2004 17:35 GMT
Instead of manually modifying the huge file that will be generated, you can
perform a search & replace in VS with regular a expression as explained in
http://weblogs.asp.net/cazzu/archive/2003/08/26/25460.aspx, and you'll get
all public properties and be ready to data bind to the DataGrid

Signature
Daniel Cazzulino [MVP XML]
Clarius Consulting SA
http://weblogs.asp.net/cazzu
http://aspnet2.com
> Ok, here's what I did and it seems to get pretty close without too much
> effort.
[quoted text clipped - 5 lines]
>
> Response.Document
http://msdn.microsoft.com/library/en-us/rssdk/html/rsxsdResponseDocument.asp
> Types
> http://msdn.microsoft.com/library/en-us/rssdk/html/rsxsdTypes.asp
>
> You may also need Response Content, Response Form (depending on what your
> queries return). eg
http://msdn.microsoft.com/library/en-us/rssdk/html/rsxsdResponseContent.asp
> http://msdn.microsoft.com/library/en-us/rssdk/html/rsxsdResponseForm.asp
>
[quoted text clipped - 138 lines]
> > *** Sent via Devdex http://www.devdex.com ***
> > Don't just participate in USENET...get rewarded for it!