So Lost on this Extractor
Here is a snippet of code that is returned after you submit a tracking request on our internal tracking website. The code that is returned seems to be XML vs HTML. For the life of me I can not get an extractor pattern to work on any of it except the tracking field. I would like to get the other fields, but completely lost.
X-Total-Records: 1
Content-Length: 136391
X-More-Data: N
Date: Sat, 16 Jan 2010 01:09:18 GMT
Content-Type: text/plain
X-Data-Source: SEP_CONS
X-Powered-By: Servlet/2.5 JSP/2.1
<?xml version="1.0" encoding="UTF-8"?>
<EnhancedEvent>
<master-list-history>
<MasterList>
<track-begin-function-time>0935</track-begin-function-time>
<track-date>20100114</track-date>
<track-end-function-time>1108</track-end-function-time>
<track-location-code>ANCEP</track-location-code>
<track-scan-time>1108</track-scan-time>
<track-type>12</track-type>
<track-source-cd>=</track-source-cd>
<track-gmt-post-date>20100114</track-gmt-post-date>
<track-gmt-post-time>20100792</track-gmt-post-time>
<hub-post-dt>20100114</hub-post-dt>
<hub-srt-typ-code>D</hub-srt-typ-code>
<container-nbr>AKE37859FX</container-nbr>
<cons-nbr>304382211370</cons-nbr>
<last-five-org-cd>8030J</last-five-org-cd>
<pkg-chkd-flag>N</pkg-chkd-flag>
<conveyance-route-number>ES846</conveyance-route-number>
<tracking-item-form-cd>0501</tracking-item-form-cd>
<assoc-tracking-number-md>
<Assoc-tracking-number-grp>
<tracking-nbr>427049546232</tracking-nbr>
<type-cd>6</type-cd>
<form-cd>0441</form-cd>
<astra-label-scanned-flg>3</astra-label-scanned-flg>
<tracking-item-time>1107</tracking-item-time>
<format-cd>I</format-cd>
<association-type>C</association-type>
<astra-label-data-sans-track-nbr>4055181941000004</astra-label-data-sans-track-nbr>
</Assoc-tracking-number-grp>
<Assoc-tracking-number-grp>
<tracking-nbr>940514648639</tracking-nbr>
<type-cd>1</type-cd>
<form-cd>0430</form-cd>
<astra-label-scanned-flg>3</astra-label-scanned-flg>
<tracking-item-time>1107</tracking-item-time>
<format-cd>I</format-cd>
<association-type>C</association-type>
<astra-label-data-sans-track-nbr>4022081941000004</astra-label-data-sans-track-nbr>
</Assoc-tracking-number-grp>
<Assoc-tracking-number-grp>
<tracking-nbr>867208306494</tracking-nbr>
<type-cd>6</type-cd>
<form-cd>0440</form-cd>
<astra-label-scanned-flg>3</astra-label-scanned-flg>
<tracking-item-time>1107</tracking-item-time>
<format-cd>I</format-cd>
<association-type>C</association-type>
<astra-label-data-sans-track-nbr>4036621941000004</astra-label-data-sans-track-nbr>
</Assoc-tracking-number-grp>
<Assoc-tracking-number-grp>
<tracking-nbr>862722930917</tracking-nbr>
<type-cd>1</type-cd>
<form-cd>0402</form-cd>
<astra-label-scanned-flg>3</astra-label-scanned-flg>
<tracking-item-time>1107</tracking-item-time>
<format-cd>I</format-cd>
<association-type>C</association-type>
<astra-label-data-sans-track-nbr>4036621941000004</astra-label-data-sans-track-nbr>
</Assoc-tracking-number-grp>
</assoc-tracking-number-md>
<cons-container-type-cd>U</cons-container-type-cd>
<cons-category>O</cons-category>
<cons-create-date>20100114</cons-create-date>
<cons-create-time>1108</cons-create-time>
<employee-base-loc-cd>ANCIP</employee-base-loc-cd>
<employee-current-mgr-cd>01</employee-current-mgr-cd>
<employee-perm-org-code>101D28030J</employee-perm-org-code>
<minisort-flag>Y</minisort-flag>
<track-transmit-code>H</track-transmit-code>
<scanning-loc-id>ANCEP</scanning-loc-id>
<post-date>20100114</post-date>
<post-time>1110</post-time>
<track-begin-function-date>20100114</track-begin-function-date>
<track-end-function-date>20100114</track-end-function-date>
<post-program>BZT595</post-program>
<processing-state>SEO</processing-state>
<admin-loc-code>ANCEP</admin-loc-code>
<astra-label-data>4055181941000004</astra-label-data>
<event-creation-timestamp>20100114200800Z-0900</event-creation-timestamp>
<device-id>TNE8510160</device-id>
<device-type>=</device-type>
<event-sequence-nbr>316815008743</event-sequence-nbr>
<event-timestamp-md>
<tracker-to-shoe-time>1103</tracker-to-shoe-time>
</event-timestamp-md>
<cons-create-loc-id>ANCEP</cons-create-loc-id>
<cons-create-employee-nbr>407534</cons-create-employee-nbr>
<cons-destination-loc-id>PVGIP</cons-destination-loc-id>
<cons-uld-number>AKE37859FX</cons-uld-number>
<sep-gmt-post-timestamp>20100114201008743Z</sep-gmt-post-timestamp>
<derived-track-loc-info-group>
<track-loc-iata-cd>ANC</track-loc-iata-cd>
<gmt-offset>-540</gmt-offset>
<prod-test-ind>P</prod-test-ind>
<event-time-zone>Y</event-time-zone>
<admin-loc-code>ANCEP</admin-loc-code>
<current-loc-type>HU</current-loc-type>
<track-city-zip-code>99502</track-city-zip-code>
<track-state-code>AK</track-state-code>
<track-country-code>US</track-country-code>
<track-city-name>ANCHORAGE</track-city-name>
<daylight-savings-time-flg>Y</daylight-savings-time-flg>
<famis-flg>N</famis-flg>
<district-location-code>ANHWK</district-location-code>
<region-location-code>WESVK</region-location-code>
</derived-track-loc-info-group>
<sep-internal-fields-md>
<sep-fields-set>Y</sep-fields-set>
<lssi-derived-location-type>HU</lssi-derived-location-type>
<lssi-derived-track-location-iata-code>ANC</lssi-derived-track-location-iata-code>
<ea-match-score>--</ea-match-score>
<scan-hash-value>cEc9.hwDb4aGw04</scan-hash-value>
<lssi-derived-track-gmt-offset-minutes>-540</lssi-derived-track-gmt-offset-minutes>
<jms-header-info>
<JMS-header>
<property-name>FormCd</property-name>
<property-value>0501</property-value>
</JMS-header>
<JMS-header>
<property-name>MsgSource</property-name>
<property-value>essfee04.prod.fedex.com</property-value>
</JMS-header>
<JMS-header>
<property-name>TrackLocCd</property-name>
<property-value>ANCEP</property-value>
</JMS-header>
<JMS-header>
<property-name>DeviceId</property-name>
<property-value>TNE8510160</property-value>
</JMS-header>
<JMS-header>
<property-name>JMS_TIBCO_PRESERVE_UNDELIVERED</property-name>
<property-value>TRUE</property-value>
</JMS-header>
<JMS-header>
<property-name>EmpNbr</property-name>
<property-value>407534</property-value>
</JMS-header>
<JMS-header>
<property-name>Hash</property-name>
<property-value>29</property-value>
</JMS-header>
<JMS-header>
<property-name>ConsNbr</property-name>
<property-value>304382211370</property-value>
</JMS-header>
<JMS-header>
<property-name>DeviceType</property-name>
<property-value>=</property-value>
</JMS-header>
<JMS-header>
<property-name>HashId</property-name>
<property-value>29</property-value>
</JMS-header>
<JMS-header>
<property-name>MessageType</property-name>
<property-value>12</property-value>
</JMS-header>
<JMS-header>
<property-name>MsgUser</property-name>
<property-value>ESS</property-value>
</JMS-header>
<JMS-header>
<property-name>JMS_TIBCO_COMPRESS</property-name>
<property-value>TRUE</property-value>
</JMS-header>
<JMS-header>
<property-name>MsgCharCd</property-name>
<property-value>XER</property-value>
</JMS-header>
<JMS-header>
<property-name>MsgCreateTmstp</property-name>
<property-value>20100114T141007.929-0600</property-value>
</JMS-header>
</jms-header-info>
</sep-internal-fields-md>
<msg-trace-audit-group>
<Msg-trace-audit-grp>
<trace-system-name>ESS</trace-system-name>
<event-creation-timestamp>201001140935</event-creation-timestamp>
<msg-hash-desc>6E2E955257D2A11DE548430F53523299</msg-hash-desc>
</Msg-trace-audit-grp>
</msg-trace-audit-group>
<famis-reporting-location-code>ANCIP</famis-reporting-location-code>
</MasterList>
<MasterList>
<track-begin-function-time>0935</track-begin-function-time>
<track-date>20100114</track-date>
<track-end-function-time>1108</track-end-function-time>
<track-location-code>ANCEP</track-location-code>
<track-scan-time>1108</track-scan-time>
<track-type>12</track-type>
<track-source-cd>=</track-source-cd>
<track-gmt-post-date>20100114</track-gmt-post-date>
<track-gmt-post-time>20101062</track-gmt-post-time>
<hub-post-dt>20100114</hub-post-dt>
<hub-srt-typ-code>D</hub-srt-typ-code>
<container-nbr>AKE37859FX</container-nbr>
<cons-nbr>304382211370</cons-nbr>
<last-five-org-cd>8030J</last-five-org-cd>
<pkg-chkd-flag>N</pkg-chkd-flag>
<conveyance-route-number>ES846</conveyance-route-number>
<tracking-item-form-cd>0501</tracking-item-form-cd>
<assoc-tracking-number-md>
<Assoc-tracking-number-grp>
<tracking-nbr>437421301080</tracking-nbr>
<type-cd>1</type-cd>
<form-cd>0430</form-cd>
<astra-label-scanned-flg>3</astra-label-scanned-flg>
<tracking-item-time>1106</tracking-item-time>
<format-cd>I</format-cd>
<association-type>C</association-type>
<astra-label-data-sans-track-nbr>4005481941000004</astra-label-data-sans-track-nbr>
</Assoc-tracking-number-grp>
<Assoc-tracking-number-grp>
<tracking-nbr>867208306450</tracking-nbr>
<type-cd>6</type-cd>
<form-cd>0440</form-cd>
<astra-label-scanned-flg>1</astra-label-scanned-flg>
<tracking-item-time>1106</tracking-item-time>
<format-cd>I</format-cd>
<association-type>C</association-type>
</Assoc-tracking-number-grp>
<Assoc-tracking-number-grp>
<tracking-nbr>793170641609</tracking-nbr>
<type-cd>6</type-cd>
<form-cd>0441</form-cd>
<astra-label-scanned-flg>3</astra-label-scanned-flg>
<tracking-item-time>1106</tracking-item-time>
<format-cd>I</format-cd>
<association-type>C</association-type>
<astra-label-data-sans-track-nbr>4005481941000004</astra-label-data-sans-track-nbr>
</Assoc-tracking-number-grp>
<Assoc-tracking-number-grp>
<tracking-nbr>793170641642</tracking-nbr>
<type-cd>6</type-cd>
<form-cd>0441</form-cd>
<astra-label-scanned-flg>3</astra-label-scanned-flg>
<tracking-item-time>1106</tracking-item-time>
<format-cd>I</format-cd>
<association-type>C</association-type>
<astra-label-data-sans-track-nbr>4005481941000004</astra-label-data-sans-track-nbr>
</Assoc-tracking-number-grp>
xml extracting
Hi,
XML is usually very easy to extract as long as the the XML was created properly and is descriptive. I'll go through a couple of examples of items I could extract based on the XML provided above.
<?xml version="1.0" encoding="UTF-8"?>
It looks to me that MasterList is a repeating child in this XML. It appears twice in the example you've provided. This could be great place to start. If I were trying to get the following data points for each MasterList I would probably use sub extractors like so:
inside the sub extractors I could have these in separate patterns or possibly grouped together. Which ever I think made more sense.
this sub extractor patter would match 1 time for each MasterList. As long as your XML is unique and descriptive, you could pull any of the children out of MasterList with very little effort. However, sub-sub children of MasterList could get a bit more complicated. For that, you could use Manual Extracting (Professional and Enterprise versions only). Our forum is full of questions about how to use Manual Extracting and I believe our "tips, tricks, and samples" section has information too.
In essence, a manual extraction is passing a saved string of data against an extractor pattern you have specifically created for that portion of passed in data. The extractor pattern does not fire during the normal chain of extracting events, but instead is manually fired once the saved string is prepared. The return is a group of data points that can then be saved into session or dataRecord scope.
You might use manual extraction on the following example of your XML.
Because Assoc-tracking-number-grp is a child of assoc-tracking-number-md and this is a child of MasterList you would have good cause to use a manual extractor to get these sub-sub children.
Anyway. As long as the extractor patter is unique you can usually get at XML data really easily. Furthermore, it would be good to understand the limitations of scope and sub extractors.
Sub extracting will only match 1 time and it will always be the first match, whereas normal extracting can match multiple times and will create an equal number of dataRecords.
Scope is best defined here under variable scope:
scope
Hopefully this gets you moving on this XML. Thanks for the question.