Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XML to HTML rendering with VFP
Message
From
05/11/2001 14:46:50
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
05/11/2001 14:40:42
Michael Dougherty
Progressive Business Publications
Malvern, Pennsylvania, United States
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00577527
Message ID:
00577535
Views:
16
I don't know about XML, but:

For posting code to the UT, it is usually more readable if you use the HTML tag < PRE > at the beginning and < /PRE > at the end. Omit the spaces.

Hilmar.

>Let's try that again with the < and > replaced with { and }
>
>I'm attempting to use a recursive function to render HTML stored in an XML file back into HTML. If that's all it was doing, i'd have created an XSLT document to render it, but they contents of certain tags will be filled according to VFP functions and SQL:Stored Procedures.
>
>Notice the {tr id="3"} and {td} begin tags are missing, but the {input...} tags are displayed - as well as the {/td} {/tr} end tags
>
>i have no ideas left to explain this behavior... please help
>
>
>** Results ******************
>{form name="form1" action=""}
>{table border="1"}
>{tr id="1"}
>{th}Name{/th}
>
>{th}Value{/th}
>{/tr}
>
>{tr id="2"}
>{td}Entry1{/td}
>
>{td}
>{input type="text" name="entry1" value=''}{/input}
>{/td}
>{/tr}
>
>{input type="submit" name="submit" value='submit'}{/input}
>{/td}
>{/tr}
>{/table}
>{/form}
>
>******************
>Given the following XML snippet:
>{ad:body}
> {ad:entryform}
>
> {form name='form1' action=''}
> {table border='1'}
> {tr id='1'}
> {th}Name{/th}
> {th}Value{/th}
> {/tr}
> {tr id='2'}
> {td}Entry1{/td}
> {td}{input type='text' name='entry1' value='' /}{/td}
> {/tr}
> {tr id='3'}
> {td colspan='2' align='center'}
> {input type='submit' name='submit' value='submit' /}{/td}
> {/tr}
> {/table}
> {/form}
>
> {/ad:entryform}
>
>******************
>And the following 2 procedures:
>lcFormContent = This.Form0004( this.XMLS0100(toXML,[ad:body/ad:entryform/form]) )
>
> Function Form0004
> LParameters toXML
> local lcHTML, lcControlName, loChild
> lcHTML = []
>&& lcHTML = [{!--] + toXML.nodename + [--}]
> lcControlName = this.XMLS0111(toXML,[@name])
>
> If toXML.haschildnodes()
> ** If the current node has children
> lcHTML = lcHTML + [{] + this.Form0005( toXML,lcControlName )
>
> for each childnode in toXML.ChildNodes
> lcHTML = lcHTML + this.Form0004( childnode ) &&this.XMLS0110(childnode,[.]) )
> next && childnode
>
> lcHTML = lcHTML + [{/] + toXML.nodename + [}}]
> else
> Do Case
> Case toXML.nodename = [#text]
> lcHTML = lcHTML + toXML.text
> Otherwise
> lcHTML = lcHTML + [{] + this.Form0005( toXML, lcControlName )
> lcHTML = lcHTML + [{/] + toXML.nodename + [}}]
> Endcase
> Endif && toXML.haschild
> Return lcHTML
> EndFunc && Form0004
>
> Function Form0005
> LParameters toXML, tcControlName
> local lcHTML, lcParamValue
> loAttribs = this.XMLS0201(toXML,[./@*])
> lcAttribs = []
> for each loAttrib in loAttribs
> Do Case
> Case loAttrib.nodename = [value]
> lcParamValue = this.XMLS0101(this.goXML,"ad:header/ad:param[ad:p-name='" + tcControlName + "']/ad:p-value")
> lcParamValue = iif(empty(lcParamValue), loAttrib.text, lcParamValue)
> lcAttribs = lcAttribs + [ value='] + lcParamValue + [']
> Otherwise
> lcAttribs = lcAttribs + [ ] + loAttrib.xml
> EndCase
> next && loAttrib
> lcHTML = [{] + toXML.nodename + lcAttribs + [}]
> Return lcHTML
> EndFunc && Form0005
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform