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.3 Updating Data |
Use the Update method to update XML documents.
The .NET APIs use record IDs to update data. The record IDs of the data to be updated have to be obtained before updating the data. The process of using a record ID to update an XML document refers to replacing an existing XML document with a new XML document. It is not possible to update part of the data contained in an existing XML document.
The following diagram shows the process for updating data specifying a record ID.
ShunService service = new ShunService(); service.Connect(); ShunSearchRequirement req = new ShunSearchRequirement(); req.QueryExpression = "/document/base/prefecture == 'Sydney'"; req.ReturnExpression = "/"; ShunResultSet rs = service.Search( req ); (1) ShunRecord updateRecord = null; (1) foreach ( ShunRecord record in rs.Records ) { (1) if ( record.Data == "Hotel 1" ) { (1) updateRecord = record; (1) } } updateRecord.Data = updateData ; (2) ShunRecordCollection recCol = new ShunRecordCollection(); (3) recCol.Add( updateRecord ); (4) service.Update( recCol ); (5) service.Disconnect(); |
Dim service As New ShunService() service.Connect() Dim req As New ShunSearchRequirement() req.QueryExpression = "/document/base/prefecture == 'Sydney'" req.ReturnExpression = "/" Dim rs As ShunResultSet = service.Search( req ) (1) Dim updateRecord As ShunRecord = Nothing (1) For Each record As ShunRecord In rs.Records (1) If record.Data = "Hotel 1" Then (1) updateRecord = record (1) End If Next updateRecord.Data = updateData (2) Dim recCol As New ShunRecordCollection() (3) recCol.Add( updateRecord ) (4) service.Update( recCol ) (5) service.Disconnect() |
Obtain the ShunRecord object to be updated.
Set the XML documents to be updated at the ShunRecord object.
Use the following methods to set the XML documents. Refer to the table below for the methods that can be used to update XML documents.
Method or property |
Function |
---|---|
ShunRecord(String data) |
Specifies XML documents to the arguments of the constructor and creates the ShunRecord object. |
ShunRecord(ShunRecordID recordID, String data) |
Specifies record IDs and XML documents to the arguments of the constructor and creates the ShunRecord object. |
ShunRecord(ShunRecordID recordID, Stream stream) |
Specifies record IDs and XML documents to the arguments of the constructor and creates the ShunRecord object. |
Data property |
Specifies the XML documents. |
Create a ShunRecordCollection object.
Set the ShunRecord object at the ShunRecordCollection object.
Use the following methods to set the ShunRecord object. Refer to the table below for the methods that can be used to update XML documents.
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. |
Use the Update method to execute the update process.
Contents
Index
![]() ![]() |