|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] parse form data to XMLDavid A. Lee dlee at calldei.comTue Sep 8 16:42:05 PDT 2009
Probably not the most elegant way ...
==========
declare variable $s :=
"v1=v1&a1=a1&v2=v2&a2=a2&v3=v3&a3=a3" ;
let $a := tokenize($s , "&" )
for $i in 0 to xs:integer(count($a) div 2 - 1)
return <row attr='{ tokenize( $a[$i * 2 + 1 ] , "=" )[2] }'>{
tokenize( $a[($i * 2) + 2 ] , "=" )[2] }</row>
==========
David A. Lee
http://x-query.com/mailman/listinfo/talk
http://www.calldei.com
http://www.xmlsh.org
812-482-5224
Jesse Wu wrote:
> Sorry for the newbie question, I am still in the process of learning XQuery.
> What will be the the best way to get HTML form post data into a XML.
> For example:
>
> get-data returns
>
> v1=v1&a1=a1&v2=v2&a2=a2&v3=v3&a3=a3& .... v10=v10&a10=a10
>
> need to get it into XML as
>
> <row attr="a1" >v1<row>
> <row attr="a2" >v2<row>
> <row attr="a3" >v3<row>
> ....
>
> <row attr="a10" >v10<row>
>
> tried to use tokenize then string-before and after =, but could not
> figure out how to get the loop to do 2 elements for each row.
>
> {for $parsed-query-term in $parsed-data
> let $parse-query-value := substring-after($parsed-query-term,"=")
> return <row attr="{???}">{xmldb:decode($parse-query-value)}</row>
> }
>
> Thank you or your help. -Jes
> _______________________________________________
> http://x-query.com/mailman/listinfo/talk
> http://x-query.com/mailman/listinfo/talk
>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






