I am trying to get a specific child element from an XML doc based on multiple selectors. Below is what I was using to find all records with the matching room name. Note that I also need to filter by a specific date-time range based on the StartDateTime
and EndDateTime
fields. I am not a web guy so to help explain below is how I would do this in SQL:
SELECT EventName
FROM Events
WHERE RoomName = 'Ballroom A'
and StartDateTime > '2018-08-23T08:30:00' and EndDateTime < '2018-08-23T17:00:00'
$.ajax({
type: "GET",
url: "data.xml",
dataType: "xml",
success: function(xml) {
var nod = $(xml).find("Event RoomName:contains('Peacock Ballroom Salon B')");
var pNod = nod.parent();
var name = $(pNod).find("EventName");
alert(name.text());
}
});
Below is a sample record in the exact format of the XML. I have tried chaining the finds and using .has, but nothing seems to produce anything.
<GetEventsResponse>
<StatusCode>OK</StatusCode>
<StatusId>1000</StatusId>
<StatusDescription>Success</StatusDescription>
<StatusException/>
<StatusCookie>Events came from cache</StatusCookie>
<StatusTimeStamp>2018-08-23T09:20:09.0375049-06:00</StatusTimeStamp>
<Events>
<Event>
<PropertyKey/>
<PropertyName>HERE</PropertyName>
<EventKey>...</EventKey>
<EventName>EVENT 1002</EventName>
<EventPostAs></EventPostAs>
<GroupKey/>
<GroupName/>
<GroupLogoUrl/>
<StartDateTime>2018-08-23T09:00:00</StartDateTime>
<EndDateTime>2018-08-23T17:00:00</EndDateTime>
<Building/>
<RoomKey/>
<RoomName>Ballroom A</RoomName>
<MeetingKey/>
<MeetingName/>
<MeetingPostAs/>
<MeetingType/>
<AgreedAttendance>50</AgreedAttendance>
<IsPostable>true</IsPostable>
<IsExhibit>false</IsExhibit>
<SecondaryEventPostAs/>
<SecondaryGroupName/>
<SecondaryRoomName/>
<SecondaryMeetingName/>
<SecondaryMeetingPostAs/>
<VideoWallScreen>0</VideoWallScreen>
<VideoWallPage>0</VideoWallPage>
<VideoWallLine>0</VideoWallLine>
<EventType/>
<Status/>
<StatusType/>
</Event>
</Events>
</GetEventsResponse>
Can anyone offer some assistance in what is the best method to get the data i need. Thanks.
Aucun commentaire:
Enregistrer un commentaire