MD wrote:
I want to put the xml document into the JSON like the following.
[
{
"id" : "123333",
"xmldoc": "<? xml version=\"1.0\" ?><data><link> </link></data>";
},
{
"id" : "123334",
"xmldoc": "<? xml version=\"1.0\" ?><data><link> </link></data>";
},
]
However, usually my xml document has new line for the xml document. Is there
any option to skip the new line in the JSON or I just have to remove them
manually .
Well, I turn all my server side outputs into JASONized XML
and turn them back into XML after I receive them in the browser.
Below is an example ( albeit a bulky one ) from one of my
server side proxies as a result of fetching a CNN news feed
http://rss.cnn.com/rss/cnn_world.rss
It provides me with both the JASONized XML from the RSS feed
and two callback functions. One for the javascript widget that
initiated the request and another for the connection manger
that retries failed/timed out requests.
theXMLresult={n :"rss",a:{versi on:"2.0"},c:[{n:"channel",c :[{n:"title",v:"C NN.com
-
World"},{n:"lin k",v:"http://www.cnn.com/rssclick/WORLD/?section=cnn_wo rld"},{n:"descr iption",v:"CNN. com
delivers up-to-the-minute news and information on the latest top
stories, weather, entertainment, politics and
more."},{n:"lan guage",v:"en-us"},{n:"copyri ght",v:"© 2006 Cable News
Network LP, LLLP."},{n:"pub Date",v:"Thu, 14 Sep 2006 11:13:45
EDT"},{n:"ttl", v:"10"},{n:"ima ge",c:[{n:"title",v:"C NN.com -
World"},{n:"lin k",v:"http://www.cnn.com/rssclick/WORLD/?section=cnn_wo rld"},{n:"url", v:"http://i.cnn..net/cnn/.element/img/1.0/logo/cnn.logo.rss.gi f"},{n:"width", v:"144"},{n:"he ight",v:"33"},{ n:"description" ,v:"CNN.com
delivers up-to-the-minute news and information on the latest top
stories, weather, entertainment, politics and
more."}]},{n:"item",c:[{n:"title",v:"T op Russian banker shot
dead"},{n:"link ",v:"http://www.cnn.com/rssclick/2006/BUSINESS/09/14/russia.banker/index.html?sect ion=cnn_world"} ,{n:"descriptio n",v:"The
top deputy chairman of Russia"s Central Bank died Thursday morning
after being gunned down by two assailants the night before near a Moscow
football stadium, a medical source told Russia"s state-run Interfax
news agency."},{n:"p ubDate",v:"Thu, 14 Sep 2006 03:51:31
EDT"}]},{n:"item",c:[{n:"title",v:"A lleged gunman called himself
"Angel of
Death""},{ n:"link",v:"htt p://www.cnn.com/rssclick/2006/WORLD/americas/09/14/montreal.shooti ng/index.html?sect ion=cnn_world"} ,{n:"descriptio n",v:"The
alleged gunman in a Montreal college shooting called himself the
"Angel of Death" in an online profile, Canadian media
say."},{n:"pubD ate",v:"Thu, 14 Sep 2006 10:56:10
EDT"}]},{n:"item",c:[{n:"title",v:"M uslim bomber guilty of killing
17"},{n:"link", v:"http://www.cnn.com/rssclick/2006/WORLD/asiapcf/09/14/india.terrortri al/index.html?sect ion=cnn_world"} ,{n:"descriptio n",v:"An
Indian court found Mohammed Ghansar guilty of murder Thursday for his
role in a string of bombings that blasted through the country"s
commercial capital, Mumbai, 13 years ago, killing 257
people."},{n:"p ubDate",v:"Thu, 14 Sep 2006 05:59:36
EDT"}]},{n:"item",c:[{n:"title",v:"B uilders hurt in airport roof
fall"},{n:"link ",v:"http://www.cnn.com/rssclick/2006/WORLD/europe/09/14/spain.collapse/index.html?sect ion=cnn_world"} ,{n:"descriptio n",v:"Twenty
people were trapped for a time Thursday at Spain"s Menorca airport
when a roof collapsed at an airport, according to CNN+ quoting the
Balearics regional government."},{ n:"pubDate",v:" Thu, 14 Sep 2006
07:53:43 EDT"}]},{n:"item",c:[{n:"title",v:"U kraine "shelve s bid to
join
NATO""},{n :"link",v:"http ://www.cnn.com/rssclick/2006/WORLD/europe/09/14/ukraine.nato.re ut/index.html?sect ion=cnn_world"} ,{n:"descriptio n",v:"Read
full story for latest details."},{n:" pubDate",v:"Thu , 14 Sep 2006
08:41:48 EDT"}]},{n:"item",c:[{n:"title",v:"D rone photo said to show
Taliban"},{n:"l ink",v:"http://www.cnn.com/rssclick/2006/WORLD/asiapcf/09/14/afghan.drone.ap/index.html?sect ion=cnn_world"} ,{n:"descriptio n",v:"Read
full story for latest details."},{n:" pubDate",v:"Thu , 14 Sep 2006
03:42:30 EDT"}]},{n:"item",c:[{n:"title",v:"K enya now cocaine
trafficking
hub"},{n:"link" ,v:"http://www.cnn.com/rssclick/2006/WORLD/africa/09/13/kenya.coke.ap/index.html?sect ion=cnn_world"} ,{n:"descriptio n",v:"Read
full story for latest details."},{n:" pubDate",v:"Wed , 13 Sep 2006
23:09:47 EDT"}]},{n:"item",c:[{n:"title",v:"H ouses raided after deadly
Turkey
blast"},{n:"lin k",v:"http://www.cnn.com/rssclick/2006/WORLD/europe/09/13/turkey.blast/index.html?sect ion=cnn_world"} ,{n:"descriptio n",v:"Police
have raided houses in the southeastern Turkish city of Diyarbakir,
according to reports, after a bomb blast Tuesday evening killed 11
people -- many of them children -- and wounded at least a dozen
more."},{n:"pub Date",v:"Wed, 13 Sep 2006 12:09:28
EDT"}]},{n:"item",c:[{n:"title",v:"C ollege gunman dies after
rampage"},{n:"l ink",v:"http://www.cnn.com/rssclick/2006/WORLD/americas/09/13/montreal.shooti ng/index.html?sect ion=cnn_world"} ,{n:"descriptio n",v:"A
gunman was killed by police and 20 students wounded after a shooting at
a college in Montreal, police said. Initial reports indicated up to four
people were killed, but Yvan Delorme, chief of Montreal Police Services,
clarified the number of dead."},{n:"pub Date",v:"Wed, 13 Sep 2006
22:50:24 EDT"}]},{n:"item",c:[{n:"title",v:"Z imbabwe arrests union
leaders"},{n:"l ink",v:"http://www.cnn.com/rssclick/2006/WORLD/africa/09/13/zimbabwe.ap/index.html?sect ion=cnn_world"} ,{n:"descriptio n",v:"Read
full story for latest details."},{n:" pubDate",v:"Wed , 13 Sep 2006
12:41:04 EDT"}]}]}]}
if(wFeedLoadCat ch)wFeedLoadCat ch(theXMLresult )
if(typeof
LAMPtransact_th robber!='undefi ned')LAMPtransa ct_throbber({co nfirmed:'XMLrel ay',cgi:'F1XMLr elay.cgi',args: 'F1_JASONcallba ck=wFeedLoadCat ch&F1_KEYRUN=41 B6767P61jLke934 9495VdOP6zQRPXb cABChinYZPPPXbc ABChinYZaoD6F7K 012j8kl9m34E5Ld eOfgMpNSTUVWqrs tuGHIJvwxy&F1_J ASON=true'});