不使用XSL即可将XML转换为HTML [英] Convert XML to HTML without using XSL

查看:88
本文介绍了不使用XSL即可将XML转换为HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我必须完成一项作业,其中必须将XML转换为HTML,而不能动态使用XSL.

请在c#/JQuery中提出一些建议.

Hi,

I have assignment in which i have to Convert XML to HTML without using XSL dynamically.

Please suggest some thing in c#/JQuery.

推荐答案

您会看到,您说的是不动态使用XSL".由于我不知道静态使用XSL"是什么意思,所以我可以将这个问题解释为不使用XSL".在这种情况下,您应该解释一下,您期望得到什么而不是XSL. XSL模式定义了如何在HTML(或其他类型的文本)上映射一些XML文档.一些XML元素和/或属性被忽略,另一些XML元素和/或属性被转换为HTML元素.您应该考虑到,一种HTML是XHTML,并且所有可能的XHTML文档都是所有可能的XML文档的子集.但是,即使没有信息丢失,您也可以以HTML形式显示任何XML文档(所有文档的集合都是无限的,但是可数的,并且具有无限的集合,这是很平常的事情.)

一个不丢失信息的可能映射将是构建一个文档,该文档在Web浏览器中呈现时呈现原始的原始XML文本.是的,为什么不?这种映射不会比其他映射更好,也不会更糟.当然,此任务非常简单,因此无需讨论.可能毫无用处,但是您是否向我们解释了所有这些活动的最终目标?得出一个结论:您需要一种定义一些映射的方法.没有这样的投入,整个问题就显得毫无意义.

—SA
You see, you say "without using XSL dynamically". As I don''t know what "using XSL statically" :-) would mean, I can interpret this question as "without using XSL". In this case, you should explain, what do you expect instead of XSL. XSL schema defines how do you map some XML document on HTML (or some other kind of text). Some XML elements and/or attributes are ignored, some other are converted into some HTML elements. You should take into account, that a kind of HTML is XHTML, and all possible XHTML documents make a sub-set of all possible XML documents. Nevertheless, you can present any XML document in the form of HTML even without loss of information (sets of all documents are infinite but countable, and with infinite sets this is a usual thing).

One possible mapping without loss of information would be building a document which renders original raw XML text when presented in a Web browser. Yes, why not? This kind of mapping is not better and not worse than any other. Of course, this task is so simple that there is nothing to discuss; and it can be quite useless, but did you explain to us the ultimate goal of all this activity? To come to a conclusion: you need a way to define some mapping; without such input the whole question looks pointless.

—SA


好吧,您是否考虑过使用XMLDOM?可能是 [ [
well, have you thought of using XMLDOM? may be this[^] and this[^] might get you started. Load the XML and the rest is history what you want your HTML to look like.


这篇关于不使用XSL即可将XML转换为HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆