看板 MacDev 關於我們 聯絡資訊
※ 引述《starkite (可樂果)》之銘言: : 不好意思 請問大家 : 使用xmlParser : <a> 節點內放任何中文都可以解析</a> : <link url="http://www.google.com.tw/"/> 直接解析放入網址的節點也可以 我在xml的節點內放入類似像這樣的html <summary type="html"> <img src="http://earthquake.usgs.gov/images/globes/40_85.jpg" alt="42.185°N 84.887°E" align="left" hspace="20" /><p>Sunday, May 8, 2011 23:30:45 UTC<br>Monday, May 9, 2011 07:30:45 AM at epicenter</p><p><strong>Depth</strong>: 35.80 km (22.25 mi)</p> </summary> 複製代碼 這樣我只需要解析summary節點 還是type或是內容也需要解析? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.135.194.85
popcorny:你應該隨便先找個rss feed的xml來參考一下 05/09 11:34
popcorny:然後再找一個opensource rss parser來參考他怎麼parse的 05/09 11:34
starkite:我是找了官方的例子SeismicXMLApp 看他網頁的原始碼 05/09 19:31
starkite:才知道可以在節點加入type="html" 就可以放入html 05/09 19:31
starkite:只是找不到方法去解析 只解析節點summary是沒有資料的 05/09 19:32
popcorny:這個範例是連到http://goo.gl/XQ6db這個rss feed 05/09 20:29
popcorny:summary type="html"是atom定的 跟xml paring完全無關 05/09 20:30
popcorny:你要做的適當你parse到你包含html的element時.. 05/09 20:30
popcorny:透過parser:foundCDATA去把html string抓回來 05/09 20:33
starkite:謝謝P大的講解 那...請問要如何parse到包含html的element 05/09 23:24
starkite:還沒找到包含html的xml opensource 不好意思一直麻煩... 05/09 23:25
popcorny:如果直接parse html. 首先你要確定你的html是xml格式 05/10 09:17
popcorny:例如你的<br>要改成<br /> 05/10 09:18