这是我的第一条消息,我有以下XML
<?xml version="1.0" encoding="UTF-8"?>
<searchResponse>
<Devices>
<Device>
<DeviceId>222</DeviceId>
<DeviceNickName>Phone</DeviceNickName>
<DeviceTypeCode>01</DeviceTypeCode>
<MappingStatusHistorys>
<MappingStatusHistory>
<Status>A</Status>
<StatusDescription>AMS Managed</StatusDescription>
<Date>2015-06-25T06:00:46-05:00</Date>
</MappingStatusHistory>
<MappingStatusHistory>
<Status>SI</Status>
<StatusDescription>Suspended By Issuer</StatusDescription>
<Date>2015-06-25T06:00:15-05:00</Date>
</MappingStatusHistory>
<MappingStatusHistory>
<Status>A</Status>
<StatusDescription>AMS Managed</StatusDescription>
<Date>2015-06-25T05:52:21-05:00</Date>
</MappingStatusHistory>
</MappingStatusHistorys>
<StatusHistorys />
<ProvisionPath>Yellow</ProvisionPath>
</Device>
</Devices>
<Response>
<ResponseCode>00</ResponseCode>
<Description>SUCCESS</Description>
</Response>
</searchResponse>
我希望得到<MappingStatusHistory> -> <Status>
的最后一个节点的<Date>
和<Status> ="A"
我真的认为用XSLT是不可能的,有任何想法的专家。
由于
答案 0 :(得分:1)
根据您提供的内容,您可以尝试以下内容:
var VenueSchema = new Schema({
name : {type : String, trim : true, lowercase : true, index: true, required: true}
, details : {
location : {
unit : {type : String, trim : true, lowercase : true}
, floor : {type : String, lowercase : true, trim : true}
, streetNumber : {type : String, trim : true, lowercase : true}
, streetName : {type : String, trim : true, lowercase : true, index: true}
, suburb : {type : String, trim : true, lowercase : true}
, city : {type : String, trim : true, lowercase : true}
, postcode : {type : String, trim : true, lowercase : true, required: true}
, state : {type : String, trim : true, lowercase : true, required: true}
, country : {type : String, trim : true, lowercase : true}
, displayAddress: POPULATE THIS FIELD ON EVERY QUERY
}
}
});
// Run this method everytime a document is requested and populate 'details.location.displayAddress'
VenueSchema.methods.getShortName = function() {
pseudo code:
this.details.location.displayAddress = this.name + this.location.unit + ' ' + this.details.location.floor ...etc
};