XmlFilterReader Class Content Studio 5.7 SDK
Content Studio Web Content Management System

[This is preliminary documentation and is subject to change.]

Provides a way of reading a forward-only stream of rows from an XmlFilter query. This class cannot be inherited.
Inheritance Hierarchy

SystemObject
  ContentStudio.Document.EPTXmlFilterReader

Namespace: ContentStudio.Document.EPT
Assembly: CSServer5 (in CSServer5.dll) Version: 5.7.5016.0 (5.7.5016.0)
Syntax

public sealed class XmlFilterReader : IDisposable

The XmlFilterReader type exposes the following members.

Properties

  NameDescription
Public propertyFieldCount
Gets the number of columns in the current row.
Public propertyIsClosed
Gets a value that indicates whether the object is closed or not
Public propertyItemInt32
Gets the value of a column given the column ordinal.
Public propertyItemString
Gets the value of a column given the column name.
Public propertyRecordsRead
Returns the number of records read so far.
Top
Methods

  NameDescription
Public methodClose
Closes the object and frees its underlying resources.
Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodGetValueAsDateTime(Int32)
Gets the value of a column as an DateTime given the column ordinal.
Public methodGetValueAsDateTime(String)
Gets the value of a column as an DateTime given the column name.
Public methodGetValueAsInt(Int32)
Gets the value of a column as an Int32 given the column ordinal.
Public methodGetValueAsInt(String)
Gets the value of a column as an Int32 given the column name.
Public methodRead
Advances the XmlFilterReader to the next record.
Public methodToString (Inherited from Object.)
Top
Remarks

The XmlFilterReader can only be used as a return value from a filter operation with XmlFilter class. When loaded XmlFilterReader contains all the fields specified by the caller and the documentid id field that always is present if any records were found.
Examples

The following sample code shows how you can use the XmlFilter class to perform an Xml filter query in Content Studio. In this code two fields return data (Head and Intro) and two additional fields (Area and CS_PublishDate) is used for filtering and sorting only. The data is returned as an XmlFilterReader object that we can use to navigate through the returned data. Notice the pattern used to be able to read the data in pages. The reader can only read the rows contained on one page, so in order to read multiple data pages you need close and reopen the reader using another data page.
Also notice the usage of the using construction to ensure that each reader instance is properly closed.
int CategoryID = 168;
//Create a new instance of the XmlFilter object
ContentStudio.Document.EPT.XmlFilter xfi = new ContentStudio.Document.EPT.XmlFilter(CS_ConnectionId, CS_UserSessionId, CategoryID);
//Add the two fields that return data first the default String datatype
xfi.AddField("Head", true);
xfi.AddField("Intro", true);
//Add fields to filter and sort on that does not return data
xfi.AddField("Area", ContentStudio.Document.EPT.XmlIndexQuery.QueryDataTypes.Integer);
xfi.AddField("CS_PublishDate", ContentStudio.Document.EPT.XmlIndexQuery.QueryDataTypes.DateTime);
//Define a criteria and a sort command
xfi.FilterCriteria = "[Area] > 1173";
xfi.SortCommand = "[CS_PublishDate] DESC";
//Limit the number of records
xfi.PageSize = 10;

Response.Write("<table>" + Environment.NewLine);
//perform the filter operation and read the data using an XmlFilterReader
//until the last page has been reached
do
{
    using (XmlFilterReader xre = xfi.FilterReader())
    {
        //Get the data
        while (xre.Read())
        {
           Response.Write("<tr>" + Environment.NewLine);
           Response.Write("<td>" + Server.HtmlEncode(xre["Head"]) + "</td>");
           Response.Write("<td>" + Server.HtmlEncode(xre["Intro"]) + "</td>");
           Response.Write("</tr>" + Environment.NewLine);
        }
    }
    //Move to the next data page
    xfi.PageNumber++;
}(while xfi.PageNumber <= xfi.PageCount);
Response.Write("</table>" + Environment.NewLine);
See Also

Reference