Formidable and Extracting Nested File Data -- Express 4 and Formidable



I have formidable accepting a POST request from an external server and as of right now, I just have it spitting out raw data from the POST, in this case it is XML.


All I care about in the post is a Base64 String so that I can decode it and store it as an image file, but it is heavily nested and despite my best efforts, I can't figure out how to dig down into the xml file to extract the Base64 String.


This is what the returned value looks like:



{ xml: '<?xml version="1.0"?>
<InboundPostRequest>
<AccessControl>
<UserName>test</UserName>
<Password>test</Password>
</AccessControl>
<RequestControl>
<RequestDate>08/18/2005 12:02:25</RequestDate>
<RequestType>New Inbound</RequestType>
</RequestControl>
<FaxControl>
<AccountID>1234567890</AccountID>
<NumberDialed>0987654321</NumberDialed>
<DateReceived>08/18/2005 12:02:13</DateReceived>
<FaxName>SampleOut</FaxName>
<FileType>pdf</FileType>
<PageCount>5</PageCount>
<CSID>8587123600</CSID>
<ANI>8587123600</ANI>
<Status>0</Status>
<MCFID>12345678</MCFID>
<UserFieldControl>
<UserFieldsRead>2</UserFieldsRead>
<UserFields>
<UserField>
<FieldName>Customer Name</FieldName>
<FieldValue>John Doe</FieldValue>
</UserField>
<UserField>
<FieldName>PIN Number</FieldName>
<FieldValue>1234</FieldValue>
</UserField>
</UserFields>
</UserFieldControl>
<BarcodeControl>
<BarcodesRead>5</BarcodesRead>
<Barcodes>
<Barcode>
<Key>EFAXTEST1A</Key>
<AdditionalInfo>
<ReadSequence>1</ReadSequence>
<ReadDirection>2-Dimentional</ReadDirection>
<Symbology>DATAMATRIX</Symbology>
<CodeLocation>
<PageNumber>1</PageNumber>
<PageCoordinates>
<StartEdge>
<XStartPointA>278.0</XStartPointA>
<YStartPointA>577.0</YStartPointA>
<XStartPointB>278.0</XStartPointB>
<YStartPointB>299.0</YStartPointB>
</StartEdge>
<EndEdge>
<XEndPointA>545.0</XEndPointA>
<YEndPointA>299.0</YEndPointA>
<XEndPointB>545.0</XEndPointB>
<YEndPointB>577.0</YEndPointB>
</EndEdge>
</PageCoordinates>
</CodeLocation>
</AdditionalInfo>
</Barcode>
<Barcode>
<Key>EFAXTEST2A</Key>
<AdditionalInfo>
<ReadSequence>1</ReadSequence>
<ReadDirection>2-Dimentional</ReadDirection>
<Symbology>DATAMATRIX</Symbology>
<CodeLocation>
<PageNumber>2</PageNumber>
<PageCoordinates>
<StartEdge>
<XStartPointA>278.0</XStartPointA>
<YStartPointA>600.0</YStartPointA>
<XStartPointB>278.0</XStartPointB>
<YStartPointB>320.0</YStartPointB>
</StartEdge>
<EndEdge>
<XEndPointA>545.0</XEndPointA>
<YEndPointA>320.0</YEndPointA>
<XEndPointB>545.0</XEndPointB>
<YEndPointB>600.0</YEndPointB>
</EndEdge>
</PageCoordinates>
</CodeLocation>
</AdditionalInfo>
</Barcode>
<Barcode>
<Key>EFAXTEST3A</Key>
<AdditionalInfo>
<ReadSequence>1</ReadSequence>
<ReadDirection>2-Dimentional</ReadDirection>
<Symbology>DATAMATRIX</Symbology>
<CodeLocation>
<PageNumber>3</PageNumber>
<PageCoordinates>
<StartEdge>
<XStartPointA>277.0</XStartPointA>
<YStartPointA>608.0</YStartPointA>
<XStartPointB>277.0</XStartPointB>
<YStartPointB>328.0</YStartPointB>
</StartEdge>
<EndEdge>
<XEndPointA>545.0</XEndPointA>
<YEndPointA>328.0</YEndPointA>
<XEndPointB>545.0</XEndPointB>
<YEndPointB>608.0</YEndPointB>
</EndEdge>
</PageCoordinates>
</CodeLocation>
</AdditionalInfo>
</Barcode>
<Barcode>
<Key>EFAXTEST4A</Key>
<AdditionalInfo>
<ReadSequence>1</ReadSequence>
<ReadDirection>2-Dimentional</ReadDirection>
<Symbology>DATAMATRIX</Symbology>
<CodeLocation>
<PageNumber>4</PageNumber>
<PageCoordinates>
<StartEdge>
<XStartPointA>277.0</XStartPointA>
<YStartPointA>608.0</YStartPointA>
<XStartPointB>277.0</XStartPointB>
<YStartPointB>328.0</YStartPointB>
</StartEdge>
<EndEdge>
<XEndPointA>545.0</XEndPointA>
<YEndPointA>328.0</YEndPointA>
<XEndPointB>545.0</XEndPointB>
<YEndPointB>608.0</YEndPointB>
</EndEdge>
</PageCoordinates>
</CodeLocation>
</AdditionalInfo>
</Barcode>
<Barcode>
<Key>EFAXTEST5A</Key>
<AdditionalInfo>
<ReadSequence>1</ReadSequence>
<ReadDirection>2-Dimentional</ReadDirection>
<Symbology>DATAMATRIX</Symbology>
<CodeLocation>
<PageNumber>5</PageNumber>
<PageCoordinates>
<StartEdge>
<XStartPointA>277.0</XStartPointA>
<YStartPointA>608.0</YStartPointA>
<XStartPointB>277.0</XStartPointB>
<YStartPointB>328.0</YStartPointB>
</StartEdge>
<EndEdge>
<XEndPointA>545.0</XEndPointA>
<YEndPointA>328.0</YEndPointA>
<XEndPointB>545.0</XEndPointB>
<YEndPointB>608.0</YEndPointB>
</EndEdge>
</PageCoordinates>
</CodeLocation>
</AdditionalInfo>
</Barcode>
</Barcodes>
</BarcodeControl>
<FileContents>//This is the Element I need to extract for decoding.
//I Removed the Base 64 String for Legibility
</FileContents>
</FaxControl>
</InboundPostRequest>

No comments:

Post a Comment