Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with XMLToCursor() 1

Status
Not open for further replies.
Oct 21, 2002
22
US

Hello everyone,

I am consuming an XML response from a web service. Everything is working great with the exception that when I convert the XML to a cursor fields that contain _numbers_ starting with 0 the field that XMLToCursor() creates is numeric and the the leading '0' is dropped. (think of a zip code 09810)

My question is, is there an easy way to instruct XMLToCursor() to force all incoming fields to type Character?

I'm not getting a schema from the service and while _I think_ I could write one and try to force XMLToCursor() to use it, I would prefer not to have to do that.

Thanks for any help you may provide.
 
If no schema is given, it is inferred (that's just an euphemism for "guessed").

And there is no flag indicating to VFP, that leading zeros are a premise for a string field.

You can indeed create a cursor with char fields to import:
Code:
Create Cursor curtest (zip c(5), enterdate D)
Insert into curtest values ('09876',Date())
CursorToXML('curTest','lcXML')
Create Cursor curTest2 (zip c(5), enterdate c(10))
XMLToCursor(lcXML,'curTest2',8192) && flag 8192 is important here
Browse

Bye, Olaf.
 
Thank you Olaf. Not the answer I was hoping for, but your response was helpful.

Enjoy the weekend. :)
 
Thanks,

I was already, coming back from a family gathering.

I assume you would rather want to taky any xml in as char. It's not impossible to parse out the field names an xml file contains and then start with all M or C(255) fields.

But in the end you need to know what field types to expect from some web service call.

As long as it's a soap web service there are other ways than to use XMLTOCURSOR. But if the service lacks a schema definition there's also no magic soap can do. Take a shot at Tools->Task Pane->XML Web Services

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top