Web Connection
Converting XML to cursor
Gravatar is a globally recognized avatar based on your email address. Converting XML to cursor
  Josh Klein
  All
  Dec 8, 2018 @ 11:44am

Getting "LOTYPE is not an object" in wwxml buildcursorfromxml when trying to use response from twilio. The xml file starts like this:

</<?xml version="1.0" encoding="UTF-8"?>

-<TwilioResponse>


-<SMSMessages uri="/2010-04-01/Accounts/ACedfc72b8312324ac121217/SMS/Messages?PageSize=50&Page=0" start="0" previouspageuri="" pagesize="50" page="0" nextpageuri="" firstpageuri="/2010-04-01/Accounts/ACedfc72b22222ac93d5787/SMS/Messages?PageSize=50&Page=0" end="21">


-<SMSMessage>

<Sid>SM92feef24f916e9a4e0f490a0940974d0</Sid>

<DateCreated>Sun, 02 Dec 2018 19:40:59 +0000</DateCreated>

<DateUpdated>Sun, 02 Dec 2018 19:41:00 +0000</DateUpdated>

<DateSent>Sun, 02 Dec 2018 19:41:00 +0000</DateSent>

<AccountSid>ACedfc72b83123423933333387</AccountSid>

<To>+15086222227</To>

<From>+1333333047</From>

<Body>Boo</Body>

<Status>received</Status>

<Direction>inbound</Direction>

<Price>-0.00750</Price>

<PriceUnit>USD</PriceUnit>

<ApiVersion>2010-04-01</ApiVersion>

<Uri>/2010-04-01/Accounts/ACedfc72b831212122227/SMS/Messages/SM92feef24f916e9a4e0f490a0940974d0</Uri>

<NumSegments>1</NumSegments>

Something else I need to do here? Thanks,

Gravatar is a globally recognized avatar based on your email address. re: Converting XML to cursor
  Tore Bleken
  Josh Klein
  Dec 8, 2018 @ 11:47pm

What you show, is not XML.

Gravatar is a globally recognized avatar based on your email address. re: Converting XML to cursor
  Josh Klein
  Tore Bleken
  Dec 9, 2018 @ 04:26am

Could be Twilio's version of xml. 2nd try below

<?xml version="1.0" encoding="UTF-8"?>
-<TwilioResponse>
-<SMSMessages uri="/2010-04-01/Accounts/ACedfc78ebcdf7cac97/SMS/Messages?PageSize=50&Page=0" start="0" previouspageuri="" pagesize="50" page="0" nextpageuri="" firstpageuri="/2010-04-01/Accounts/ACedfc72b83b4008a8ebcdf77/SMS/Messages?PageSize=50&Page=0" end="21">
-<SMSMessage>
<Sid>SM92feef24f916e9a4d0</Sid>
<DateCreated>Sun, 02 Dec 2018 19:40:59 +0000</DateCreated>
<DateUpdated>Sun, 02 Dec 2018 19:41:00 +0000</DateUpdated>
<DateSent>Sun, 02 Dec 2018 19:41:00 +0000</DateSent>
<AccountSid>ACedfc72b83b4008a8ebcdf77</AccountSid>
<To>+15086905727</To>
<From>+17817841237</From>
<Body>Boo</Body>
<Status>received</Status>
<Direction>inbound</Direction>
<Price>-0.00750</Price>
<PriceUnit>USD</PriceUnit>
<ApiVersion>2010-04-01</ApiVersion>
<Uri>/2010-04-01/Accounts/ACedfc72b83b4008a8eb87/SMS/Messages/SM92feef24f916e9a4e0f490a0940974d0</Uri>
<NumSegments>1</NumSegments>
</SMSMessage>

Gravatar is a globally recognized avatar based on your email address. re: Converting XML to cursor
  Tore Bleken
  Josh Klein
  Dec 9, 2018 @ 05:04am

And what's your code?

Gravatar is a globally recognized avatar based on your email address. re: Converting XML to cursor
  Josh Klein
  Tore Bleken
  Dec 9, 2018 @ 06:15am
SET PROCEDURE TO wwUtils ADDITIVE
SET PROCEDURE TO wwAPI ADDITIVE
SET PROCEDURE TO wwHTTP ADDITIVE
SET classlib TO wwxml additive
lcxml=FILETOSTR('test.xml')
loxml = Createobject("wwXML")
pfname='csrTwillXML'
lfound = loxml.Xmltocursor(lcxml,pfname)

"test.xml" is the file I created as a response from twilio of the twilio log file. The top portion of which I posted previously. The error I get,"LOTYPE is not an Object", is on this line of code in WWxml:

laFields[lnX,2] = THIS.XMLTypeToFoxType(loType.TEXT)

Gravatar is a globally recognized avatar based on your email address. re: Converting XML to cursor
  Tore Bleken
  Josh Klein
  Dec 9, 2018 @ 08:21am

My guess is that your xml is not compatible with wwxml. To me it doesn't look right, I would try to delete lines 2 and 3 of the xml.

Gravatar is a globally recognized avatar based on your email address. re: Converting XML to cursor
  Rick Strahl
  Josh Klein
  Dec 9, 2018 @ 12:41pm

Even so that result is not valid XML. The dashes outside the elements are invalid. Is that actually there or that just from what ever you are displaying the HTML in? It looks like <SmsMessage> is your actual root element and start of the XML.

If you're using wwXml::XmlToCursor() you either have to have a document with a schema (you do not) or you have to provide a cursor with the appropriate structure (ie. fields with the names of the elements) to load the data into. The reason for the error most likely is that there's nothing to get type information from.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Converting XML to cursor
  Josh Klein
  Rick Strahl
  Dec 10, 2018 @ 05:25am

The code I posted was simply displaying what Internet Explorer showed. The actual xml was one long line without any CR LF in there.

Gravatar is a globally recognized avatar based on your email address. re: Converting XML to cursor
  Tore Bleken
  Josh Klein
  Dec 10, 2018 @ 05:28am

Then show the "real" xml as "code", but please add CR LF.

Gravatar is a globally recognized avatar based on your email address. re: Converting XML to cursor
  Josh Klein
  Tore Bleken
  Dec 10, 2018 @ 05:02pm

XML data below...

<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse>
<SMSMessages end="21" firstpageuri="/2010-04-01/Accounts/ACedfc72b83b4008a8ebcdf7cac93d5787/SMS/Messages?PageSize=50&amp;Page=0" nextpageuri="" page="0" pagesize="50" previouspageuri="" start="0" uri="/2010-04-01/Accounts/ACedfc72b83b4008a8ebcdf7cac9123456/SMS/Messages?PageSize=50&amp;Page=0">
<SMSMessage>
<Sid>SM92feef24f916e9a4e0f490a0940974d0</Sid>
<DateCreated>Sun, 02 Dec 2018 19:40:59 +0000</DateCreated>
<DateUpdated>Sun, 02 Dec 2018 19:41:00 +0000</DateUpdated>
<DateSent>Sun, 02 Dec 2018 19:41:00 +0000</DateSent>
<AccountSid>ACedfc72b12345a8ebcdf7cac93d5787</AccountSid>
<To>+15086915737</To>
<From>+17817344247</From>
<Body>Boo</Body>
<Status>received</Status>
<Direction>inbound</Direction>
<Price>-0.00750</Price>
<PriceUnit>USD</PriceUnit>
<ApiVersion>2010-04-01</ApiVersion>
<Uri>/2010-04-01/Accounts/ACe1234567890008a8ebcdf7cac93d5787/SMS/Messages/SM92feef241234567890f490a0940974d0</Uri>
<NumSegments>1</NumSegments>
</SMSMessage>
<SMSMessage>
<Sid>SMb0655bafbb9ecb5d0b807c73097855fb</Sid>
<DateCreated>Sun, 02 Dec 2018 14:44:39 +0000</DateCreated>
<DateUpdated>Sun, 02 Dec 2018 14:44:39 +0000</DateUpdated>
<DateSent>Sun, 02 Dec 2018 14:44:39 +0000</DateSent>
<AccountSid>ACedfc72b83b412345678907cac93d5787</AccountSid>
<To>+15086905727</To>
<From>+17817844047</From>
<Body>Again</Body>
<Status>received</Status>
<Direction>inbound</Direction>
<Price>-0.00750</Price>
<PriceUnit>USD</PriceUnit>
<ApiVersion>2010-04-01</ApiVersion>
<Uri>/2010-04-01/Accounts/ACedfc72b1234567890bcdf7cac93d5787/SMS/Messages/SMb0655b1234567890b807c73097855fb</Uri>
<NumSegments>1</NumSegments>
</SMSMessage>
</SMSMessages>
</TwilioResponse>
Gravatar is a globally recognized avatar based on your email address. re: Converting XML to cursor
  Rick Strahl
  Josh Klein
  Dec 10, 2018 @ 11:21pm

This works:

TEXT TO lcXML NOSHOW
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse>
<SMSMessages end="21" firstpageuri="/2010-04-01/Accounts/ACedfc72b83b4008a8ebcdf7cac93d5787/SMS/Messages?PageSize=50&amp;Page=0" nextpageuri="" page="0" pagesize="50" previouspageuri="" start="0" uri="/2010-04-01/Accounts/ACedfc72b83b4008a8ebcdf7cac9123456/SMS/Messages?PageSize=50&amp;Page=0">
<SMSMessage>
<Sid>SM92feef24f916e9a4e0f490a0940974d0</Sid>
<DateCreated>Sun, 02 Dec 2018 19:40:59 +0000</DateCreated>
<DateUpdated>Sun, 02 Dec 2018 19:41:00 +0000</DateUpdated>
<DateSent>Sun, 02 Dec 2018 19:41:00 +0000</DateSent>
<AccountSid>ACedfc72b12345a8ebcdf7cac93d5787</AccountSid>
<To>+15086915737</To>
<From>+17817344247</From>
<Body>Boo</Body>
<Status>received</Status>
<Direction>inbound</Direction>
<Price>-0.00750</Price>
<PriceUnit>USD</PriceUnit>
<ApiVersion>2010-04-01</ApiVersion>
<Uri>/2010-04-01/Accounts/ACe1234567890008a8ebcdf7cac93d5787/SMS/Messages/SM92feef241234567890f490a0940974d0</Uri>
<NumSegments>1</NumSegments>
</SMSMessage>
<SMSMessage>
<Sid>SMb0655bafbb9ecb5d0b807c73097855fb</Sid>
<DateCreated>Sun, 02 Dec 2018 14:44:39 +0000</DateCreated>
<DateUpdated>Sun, 02 Dec 2018 14:44:39 +0000</DateUpdated>
<DateSent>Sun, 02 Dec 2018 14:44:39 +0000</DateSent>
<AccountSid>ACedfc72b83b412345678907cac93d5787</AccountSid>
<To>+15086905727</To>
<From>+17817844047</From>
<Body>Again</Body>
<Status>received</Status>
<Direction>inbound</Direction>
<Price>-0.00750</Price>
<PriceUnit>USD</PriceUnit>
<ApiVersion>2010-04-01</ApiVersion>
<Uri>/2010-04-01/Accounts/ACedfc72b1234567890bcdf7cac93d5787/SMS/Messages/SMb0655b1234567890b807c73097855fb</Uri>
<NumSegments>1</NumSegments>
</SMSMessage>
</SMSMessages>
</TwilioResponse>
ENDTEXT


DO wwXml
DO wwDotnetBridge

CREATE CURSOR TMessages ( sid c(40), DateCreated c(50), DateUpdated c(50), To c(80), From c(80),;
                          Price Y,Uri M, Body M, ApiVersion c(20),;
                          DateCreatedDate T, DateUpdatedDate T)


loXml = CREATEOBJECT("wwXml")
loXml.XmlToCursor(lcXml,"TMessages")


*** Fix up the non-standard dates
do wwDotNetBridge
LOCAL loBridge as wwDotNetBridge
loBridge = GetwwDotnetBridge()
replace ALL DateCreatedDate WITH loBridge.InvokeStaticmethod("System.DateTime","Parse",DateCreated),;
            DateUpdatedDate WITH loBridge.InvokeStaticmethod("System.DateTime","Parse",DateUpdated)

BROWSE
Gravatar is a globally recognized avatar based on your email address. re: Converting XML to cursor
  Josh Klein
  Rick Strahl
  Dec 11, 2018 @ 05:48pm

Outstanding!

This is great!

Thanks,

Josh

© 1996-2024