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:{version:"2.0"},c:[{n:"channel",c:[{n:"title",v:"CNN.com
-
World"},{n:"link",v:"http://www.cnn.com/rssclick/WORLD/?section=cnn_world"},{n:"description",v:"CNN.com
delivers up-to-the-minute news and information on the latest top
stories, weather, entertainment, politics and
more."},{n:"language",v:"en-us"},{n:"copyright",v:"© 2006 Cable News
Network LP, LLLP."},{n:"pubDate",v:"Thu, 14 Sep 2006 11:13:45
EDT"},{n:"ttl",v:"10"},{n:"image",c:[{n:"title",v:"CNN.com -
World"},{n:"link",v:"http://www.cnn.com/rssclick/WORLD/?section=cnn_world"},{n:"url",v:"http://i.cnn..net/cnn/.element/img/1.0/logo/cnn.logo.rss.gif"},{n:"width",v:"144"},{n:"height" ,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:"Top Russian banker shot
dead"},{n:"link",v:"http://www.cnn.com/rssclick/2006/BUSINESS/09/14/russia.banker/index.html?section=cnn_world"},{n:"description",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:"pubDate",v:"Thu, 14 Sep 2006 03:51:31
EDT"}]},{n:"item",c:[{n:"title",v:"Alleged gunman called himself
"Angel of
Death""},{n:"link",v:"http://www.cnn.com/rssclick/2006/WORLD/americas/09/14/montreal.shooting/index.html?section=cnn_world"},{n:"description",v: "The
alleged gunman in a Montreal college shooting called himself the
"Angel of Death" in an online profile, Canadian media
say."},{n:"pubDate",v:"Thu, 14 Sep 2006 10:56:10
EDT"}]},{n:"item",c:[{n:"title",v:"Muslim bomber guilty of killing
17"},{n:"link",v:"http://www.cnn.com/rssclick/2006/WORLD/asiapcf/09/14/india.terrortrial/index.html?section=cnn_world"},{n:"description",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:"pubDate",v:"Thu, 14 Sep 2006 05:59:36
EDT"}]},{n:"item",c:[{n:"title",v:"Builders hurt in airport roof
fall"},{n:"link",v:"http://www.cnn.com/rssclick/2006/WORLD/europe/09/14/spain.collapse/index.html?section=cnn_world"},{n:"description",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:"Ukraine "shelves bid to
join
NATO""},{n:"link",v:"http://www.cnn.com/rssclick/2006/WORLD/europe/09/14/ukraine.nato.reut/index.html?section=cnn_world"},{n:"description",v: "Read
full story for latest details."},{n:"pubDate",v:"Thu, 14 Sep 2006
08:41:48 EDT"}]},{n:"item",c:[{n:"title",v:"Drone photo said to show
Taliban"},{n:"link",v:"http://www.cnn.com/rssclick/2006/WORLD/asiapcf/09/14/afghan.drone.ap/index.html?section=cnn_world"},{n:"description",v: "Read
full story for latest details."},{n:"pubDate",v:"Thu, 14 Sep 2006
03:42:30 EDT"}]},{n:"item",c:[{n:"title",v:"Kenya now cocaine
trafficking
hub"},{n:"link",v:"http://www.cnn.com/rssclick/2006/WORLD/africa/09/13/kenya.coke.ap/index.html?section=cnn_world"},{n:"description",v: "Read
full story for latest details."},{n:"pubDate",v:"Wed, 13 Sep 2006
23:09:47 EDT"}]},{n:"item",c:[{n:"title",v:"Houses raided after deadly
Turkey
blast"},{n:"link",v:"http://www.cnn.com/rssclick/2006/WORLD/europe/09/13/turkey.blast/index.html?section=cnn_world"},{n:"description",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:"pubDate",v:"Wed, 13 Sep 2006 12:09:28
EDT"}]},{n:"item",c:[{n:"title",v:"College gunman dies after
rampage"},{n:"link",v:"http://www.cnn.com/rssclick/2006/WORLD/americas/09/13/montreal.shooting/index.html?section=cnn_world"},{n:"description",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:"pubDate",v:"Wed, 13 Sep 2006
22:50:24 EDT"}]},{n:"item",c:[{n:"title",v:"Zimbabwe arrests union
leaders"},{n:"link",v:"http://www.cnn.com/rssclick/2006/WORLD/africa/09/13/zimbabwe.ap/index.html?section=cnn_world"},{n:"description",v: "Read
full story for latest details."},{n:"pubDate",v:"Wed, 13 Sep 2006
12:41:04 EDT"}]}]}]}
if(wFeedLoadCatch)wFeedLoadCatch(theXMLresult)
if(typeof
LAMPtransact_throbber!='undefined')LAMPtransact_th robber({confirmed:'XMLrelay',cgi:'F1XMLrelay.cgi', args:'F1_JASONcallback=wFeedLoadCatch&F1_KEYRUN=41 B6767P61jLke9349495VdOP6zQRPXbcABChinYZPPPXbcABChi nYZaoD6F7K012j8kl9m34E5LdeOfgMpNSTUVWqrstuGHIJvwxy &F1_JASON=true'});