Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: Need Clue(s) Re Hierarchal XML Parsing

$
0
0
Re: Need Clue(s) Re Hierarchal XML Parsing
Web Connection 5.0
Re: Need Clue(s) Re Hierarchal XML Parsing
03/01/2012
04:47:25 PM
3G10ZZK93 Show this entire thread in new window
Gratar Image based on email address
From:
To:
Attachments:
None
Hi Brett,

Arbitrary objects are always difficult to parse into a structure of any sort. .NET is no different. You can map a type (class) to an XML structure provided everything is formatted properly etc. .NET does have a schema importer utility that works to create a class from a schema. You *should* then be able to read an XML stream and be able to import it into that class using the XML Serializer. It works most of the time :-) but it really depends on the quality of the data. In my experience there are little spec difference that often fail to make this work right. But it's probably as close as you get. It also requires that there's a schema available in the first place.

All that said, if you have a complex XML structure it's often easier to parse it manually. Where .NET is better is parsing XML data and traversing the XML tree. The tools are better (XLinq or even XmlDocument with XPath) than using MSXML so it can be more efficient.

My recommendation would be to build a component in .NET and then call that from VFP, rather than using all call throughs from FoxPro directly (using wwDotnetBridge). You can still use wwDotnetBridge to make registrationless calls to the .NET component you create to keep the impact in your app low, but it tends to be easier to deal with the code parsing directly in .NET rather than the indirect referencing required from Foxpro. Passing back a completely parsed structure is (object or data set possibly) is going to be easier to work with in Fox.

Hope this helps,

+++ Rick ---



Ok, this one's coming back to haunt me--BIG TIME. The project I finished up over six months ago is attempting to go live by our IT deparment and after I manually mapped everything, doing drill downs, and being satisfield it would work, I am finding all kinds of unanticipated scenarios and losing data as a result. I suspect Dot Net is much better at handling hierarchal XML.

What about using wwDotNetBridge.dll (WC 5.60)? Do you think this might be worth pursuing? I imagine I can return a populated hierarchal object or DataSet from Dot Net to Fox. Does this sound at all feasible to you?

Note I am aware of the structure; so once populated it's just a matter of drilling down thru all the nodes. It's getting the completely populated object that's my issue. Any clues appreciated (as always).


XmlAdapter supports custom schemas but it's not trivial to set this up. It's pretty work intensive. The problem is that you have to map everything manually which is almost as tediuous as writing the MSXML parsing code yourself.

Another option is to use wwXML and XmlToObject, but that too requires that you create hte object structure to parse into first.

If you manually parse wwXML has a few helpers that can make it easier to convert types from XML to Fox values.

+++ Rick ---


In my WC 5.50 app I need to import some hierarchal XML from a Java app.

Is there a way to build a fox cursor from an XML Node (HasChildren = false) using wwXML WC 5.50?

Can I, for example, select a node and use a method like BuildCursorFromXML then ParseXMLToCursor when importing XML? ... or, (i see in doc I must have DTD) is this just not possible unless the XML was build using wwXML? I have search wconnect.chm with no luck other than getting more confused maybe.

An external XSD schema is in use.

I suspect I must specify a Node and create a cursor, but is there a way to get wwXML to create the cursor from the XML when a node is specified and then populate the cursor from the node?

Any clues on a recommended method of parsing hierarchal XML to fox cursors appreciated.







Viewing all articles
Browse latest Browse all 10393

Trending Articles