Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX - |
Contents
Index
![]() ![]() |
Part 2 Developing Applications by APIs | > Chapter 10 Developing .NET Applications | > 10.3 How to Use .NET APIs | > 10.3.2 Data Searches |
When searching for a particular XML document, do not obtain the entire document immediately. Instead, start by obtaining the partial information that can effectively identify the document.
To extract the entire XML document, set the ShunRecord object that has extracted information partially in the ShunRecordCollection object, and then use the SearchByRecordID to extract the entire target XML document.
The following diagram shows the process for using record IDs to obtain an entire XML document.
ShunService service = new ShunService(); service.Connect(); ShunSearchRequirement req = new ShunSearchRequirement(); req.QueryExpression = "/document/base/prefecture == 'Sydney'"; req.ReturnExpression = "/document/base/name/text()"; ShunResultSet rs = service.Search( req ); Console.WriteLine("[Number of hits] = " + rs.HitCount); ShunRecordCollection recCol = new ShunRecordCollection(); (1) foreach ( ShunRecord record in rs.Records ) { (2) if ( record.Data == "Hotel 1" ) { (2) recCol.Add( record ); (2) } } rs = service.SearchByRecordID( recCol ); (3) foreach ( ShunRecord record in rs.Records ) { (4) Console.WriteLine( "[Detail] = " + record.Data ); (4) } service.Disconnect(); |
Dim service As New ShunService() service.Connect() Dim req As New ShunSearchRequirement() req.QueryExpression = "/document/base/prefecture == 'Sydney'" req.ReturnExpression = "/document/base/name/text()" Dim rs As ShunResultSet = service.Search( req ) Console.WriteLine( "[Number of hits] = {0}", rs.HitCount ) Dim recCol As New ShunRecordCollection() (1) For Each record As ShunRecord In rs.Records (2) If record.Data = "Hotel 1" Then (2) recCol.Add( record ) (2) End If Next rs = service.SearchByRecordID( recCol ) (3) For Each record As ShunRecord In rs.Records (4) Console.WriteLine( "[Detail] = {0}", record.Data) (4) Next service.Disconnect() |
Create a ShunRecordCollection object.
Set the ShunRecord object in the ShunRecordCollection object.
The following methods are used to set the ShunRecord object. Refer to the table below for the methods that can be used to set the ShunRecord object.
Method or property |
Function |
---|---|
Add(ShunRecord record) |
Adds the ShunRecord to the end of ShunRecordCollection. |
AddRange(ShunRecord[] records) |
Copies the element of ShunRecord array to the end of ShunRecordCollection. |
Insert(int index, ShunRecord record) |
Inserts the ShunRecord at the index position specified in the ShunRecordCollection. |
Item[int index] |
Replaces the ShunRecord that the index position is specified. |
Execute the search using the SearchByRecordID method. A ShunRecordCollection object will be created to hold the results of the search.
Extract one record of ShunRecord object from the ShunRecordCollection object. Then extract the XML documents from the ShunRecord object.
The following properties or methods are used to extract XML documents according to the purpose of the extraction. Refer to the table below for the properties and methods that can be used to extract XML documents.
Property or method |
Function |
---|---|
Data property |
Extracts XML documents as String objects. |
GetDividedData method |
Extracts XML documents as a two-dimensional array of String objects. |
GetStream method |
Extracts XML documents as Stream objects. |
Note: The GetDividedData method is an effective way to extract search results in text format.
Contents
Index
![]() ![]() |