Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Processing an XML file to VFP cursors
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Divers
Thread ID:
00904549
Message ID:
00967181
Vues:
9
Jaime,

An amazing thing happened Friday morning! I set aside the XPath route (I will check out VFP 9 Beta, however)

I told myself if I could map the structure of a hiearchial XML Document to treeview I would be in a good position to understand the content. The first thing that struck me is how "conformant" MS DOM is to the JSEE (Apache DOM). The info in the associated XSD and DTD linked, as advertised, with the MS DOM cached XML (good news for a start).

So I struggled working to build a "crawler" that would crawl through the nodes of the cached XML and render a treeview representation of the XML. I thrashed near the brink of anialation for almost 16 hours. I was surprised at how small and simple my little "crawler" was - but it was not "tiering" the nodes. So early friday morning, I moved one of the treeview "key" pointers to another place in the code - and then - just like in the "Matrix", when Neo "stopped" the bullets -everything fell in place!

It just flushed the entire DOM and cached XSD links to the treeview in the blink of an eye (some of the XMLs are big once the XSD's are binded!).

Depending on where the crawler was in the DOM, either a new treeview key would be created, or the 'parent" node of the last treeview node would be used as a reference. In cases where the crawler cycled through a "while isnull(oNodeXML.parentNode.nextSibling)" (thats the secret) - the resolver will [always] translate to the proper treeview node!

Now I have a little VFP program that will (regardless of hierarchial/tabular - my project will have both in one XML!) write a treeview and will color code the node groups based on attribute values in the DOM!

AND - It will work with any XML!

Now I have to do something with it!:-)

>Terry
>>Are there reasons certain types of XMLs will not load to XMLAdapter? I >guess I am wondering if XMLAdapter/XMLToCursor are fully W3C.
>
>Did you check XmlAdapter in the VFP9 Beta? It includes support for hierarchical XML, XPath expressions and some more stuff...
>
>Jaime
>
>>Well at least you made it back! It's nice to know someone gets vacation time!:)
>>
>>As I desperately waited for your response, I did some reading. Evan Delay was talking about this stuff two years ago, so I am behinf the times!
>>
>>What I learned is the XMLs I am usining are Hieracrhal rather rather than tablular. So I am working on a "crawler". I have the crawler working pretty well in the section of the manifest (XML) where a particular node does not have a root sibling. I am trying to get a "(leaf) crawler" working in sections of the XML where the root parent node does have siblings. ANy advice or pointers appreciated.
>>
>>However, I did find a free tool ( http://www.vbxml.com/xpathvisualizer/ ) that loads an XML and then, based the Xpath query, will highlite those nodes participating in the query results.
>>
>>Are there reasons certain types of XMLs will not load to XMLAdapter? I guess I am wondering if XMLAdapter/XMLToCursor are fully W3C.
>>
>>Thanks
>>
>>
>>>Terry
>>>Sorry , i have been away for a veeeeeeeery long time, due to huge projects that came in all together ( as always ). To answer the question you're going to ask: Yes, it's all exclusively plain-vanilla VFP, with native data and the whole panoplie...
>>>About your question concerning moving Java DOM, i don't know ditch...don't think of me as a XML guru or something, it's just that i had to learn it in order to maintain the zillion Web Services i developed with VFP the last 2 years :-)
>>>
>>>Jaime
>>>
>>>>Jamie,
>>>>Thanks for helping Carmel an I with this post.
>>>>
>>>>I am moving some Java DOM services to M$'s IXMLDOM. Could you offer any advice on that transition?
>>>>
>>>>
>>>>>Carmel
>>>>>If you use VFP8, just check out the XMLAdapter Class.
>>>>>If you are using previous versions, you should manually scan your xml using XMLDom and enter the data into your tables.
>>>>>Scannig your data manually would look something like the following:
>>>>>ox = CreateObject("MSXml.DOMDocument")
>>>>>ox.Load( YourXmlSource ) && or ox.LoadXML( YourXMLString )
>>>>>myXmlString = ox.DocumentElement
>>>>>** now retrieve some fields **
>>>>>myRevNode = myXmlString.SelectSingleNode( "authentication/revision" )
>>>>>myRevision = myRevNode.Text
>>>>>myResNode = myXmlString.SelectSingleNode( "authentication/reseller_shortcut")
>>>>>MyReseller = myResNode.Text
>>>>>
>>>>>** loop through the customer nodes
>>>>>myCustomers = myXmlString.SelectNodes( "customers" )
>>>>>for each oCostumer in myCustomers
>>>>>   tmpName = oCostumer.SelectSingleNode("customer/name")
>>>>>   ? tmpName.Text
>>>>>endfor
>>>>>** it's a pain, i know, but you can control everything
>>>>>
>>>>>HTH
>>>>>Jaime
>>>>>
Imagination is more important than knowledge
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform