Re: [問題] 請問有關 XML 的問題

看板Web_Design作者 (nigel)時間20年前 (2006/02/03 23:23), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串4/4 (看更多)
我把你的資料存進記事本,副檔名改.xml... 用ie開啟,你的資料已經分段顯示了...- -... 要把xml轉成html還必須自己撰寫.xsl 然後還要經過伺服器轉換才能呈現出html或是xhtml的效果 我po我的之前報告xml的程式碼給你參考看看吧 .xml ======================================================== <!DOCTYPE DepartmentList SYSTEM "D:\成長\XML\schema\csie.dtd"> <DepartmentList> <Title>Kaohsiung University</Title> <Department> <DepartmentName>CSIE</DepartmentName> <Postion>No.700,Kaohsiung University Rd.Nan Tzu Dist.,811.Kaohsiung,Taiwan, R.O.C.</Postion> <Tel>886-7-5919518</Tel> <Fax>886-7- 5919514</Fax> <e-mail>cs@nuk.edu.tw</e-mail> </Department> </DepartmentList> ======================================================= .xsl ======================================================= <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="" rel="nofollow">http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="big5" /> <xsl:template match="/"> <html> <head> <title><xsl:value-of select="DepartmentList/Title"/>"</title> </head> <xsl:apply-templates/> <body></body> </html> </xsl:template> <xsl:template match="DepartmentList"> <body> <h1><xsl:apply-templates/></h1> </body> </xsl:template> <xsl:template match="DepartmentList/Department"> <table> <xsl:apply-templates/> </table> </xsl:template> <xsl:template match="DepartmentList/Department/DepartmentName"> <td></td> Name: <xsl:apply-templates/> <tr></tr> </xsl:template> <xsl:template match="DepartmentList/Department/Postion"> <td></td> Postion: <xsl:apply-templates/> <tr></tr> </xsl:template> <xsl:template match="DepartmentList/Department/Tel"> <td></td> Tel: <xsl:apply-templates/> <tr></tr> </xsl:template> <xsl:template match="DepartmentList/Department/Fax"> <td></td> Fax: <xsl:apply-templates/> <tr></tr> </xsl:template> <xsl:template match="DepartmentList/Department/e-mail"> <td></td> e-mail: <xsl:apply-templates/> <tr></tr> </xsl:template> </xsl:stylesheet> ========================================================= 所以如果你想要分段顯示 可以寫一份.xsl來支援他 小弟也只有稍微接觸過XML 不知道這能不能回答到你 如有錯誤還請見諒 -- 小小的讀書心得 http://www.wretch.cc/blog/hnigel -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.171.181.130 ※ 編輯: NUKnigel 來自: 218.171.181.130 (02/03 23:31)

02/04 02:10, , 1F
謝謝... 翻了些資料 寫了xsl 檔後,應該有解決我的問題
02/04 02:10, 1F
文章代碼(AID): #13utLfDS (Web_Design)
文章代碼(AID): #13utLfDS (Web_Design)