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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xmlToCursor() hangs on spaces

Status
Not open for further replies.

peteschulte

IS-IT--Management
Nov 21, 2008
41
US
Hello Coders,
Please see the jpeg for content of the xml and the error message resulting from the program below.
When I received this error before, I went into the xml file and removed a crlf. As a result, the program processed the xml file past that point and hung on the next space in the xml.

Code:
SET DEFAULT TO C:\temp-CallDetail\12-29

Close Tables All

currentDir = SYS(5) + CURDIR()
? currentDir + CHR(13)+CHR(10)

SET STEP ON

xmlfile=("C0_5528.xml")
? xmlfile + CHR(13)+CHR(10)

xmlcontent = FILETOSTR(xmlfile)

? xmlcontent + CHR(13)+CHR(10)

xmltocursor("C0_5528_no_crlf.xml", "curC0_5528", 512)

COPY TO "C0_5528.dbf"
SET

Maybe I need the xmlAdapter object?
Is it the filetostr() conversion?
Thank you for your suggestions and Happy New Year,
 
Hi Pete.

Yes, you'll need to use XMLAdapter for this type of XML. XMLTOCURSOR() is fine for simple XML (something that would end up in a single table), but the XML you're trying to parse will end up in several tables.

Doug
 
the XML snippet shown does not seem to be completely correct, unless the standards have changed in the past couple of years :)

For one thing, where is the ending tag for "step" ?

What happens if you pass the XML snippet through an XML Validator or a stand alone XML converter?
 
the code does not seem to be tripping on spaces per se, it seems it is having problems parsing out the 'field name' as the beginning "call" tag does not have a closing ">
 
Like already said in the first question you had about xml conversion, XMLToCursor() is not for any XML. It's only good for XML representing a table (outer level) and it's records (mid level) and it's fields (inner level) and the net data is within those xml elements.

This XML does also have three levels: cdr, call and plug-in. But the net data here is not within xml elements, it's within the attributes of the nested cdr, call and plug-in elements. And thus you need to parse those xml elements and their attributes this time.

XML is not XML. XML is very specific to the specific job it's made for, it's more flexible than HTML in that the elements can be freely defined, and as you can't expect an html page to represent a table of valuey, you can't expect any XML to function with XMLToCursor.

XMLAdapter should help you more with this. Or use a COM class directly: msxml.domdocument. In both cases use their loadxml method and then their firstsibling/nextsibling etc. for navigating through the xml nodes and then look into the attributes collection.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top