[英]Bind HTML Attribute to XML Data Source
I am not that familiar with the whole SGML family... I need to develop a small website which is part of an installation process of an application. 我对整个SGML系列不是很熟悉...我需要开发一个小网站,这是应用程序安装过程的一部分。 The website shows permanently the features which were selected during the installation process.
该网站会永久显示在安装过程中选择的功能。 The website is fine - thanks to Bootstrap.
该网站很好-感谢Bootstrap。 But now I want to hide or show elements on this website according to the selection in the installation process.
但是现在我要根据安装过程中的选择隐藏或显示此网站上的元素。
During the installation I can modify an XML file. 在安装过程中,我可以修改XML文件。 My idea is to bind the HTML attributes to the XML data.
我的想法是将HTML属性绑定到XML数据。
Example XML I can modify during my installation process: 我可以在安装过程中修改的示例XML:
<features>
<feature>
<name>Feature 1</name>
<visible>hidden</visible>
<feature>
<features>
HTML idea: HTML想法:
<div class="feature1" VISIBLE_VALUE_FROM_XML>
<img src="./img/feature1"/>
</div>
Is it somehow possible to bind both? 是否可以将两者绑定? What are the relevant keywords here?
这里有哪些相关的关键字? What alternatives do I have?
我有什么选择? Do you have any good reading sources?
您有什么好的阅读资料吗?
Thanks! 谢谢!
[EDIT]: [编辑]:
Perhaps the question was too trivial for you. 也许这个问题对您来说太琐碎了。 I guess I was too limited in Data Binding thinking.
我想我在数据绑定思想方面太局限了。 So, the following steps do the trick:
因此,以下步骤可以解决问题:
Here You GO! 干得好!
With these steps you can do it. 通过这些步骤,您可以做到。
Step 1 : Convert your XML to JSON using any one of the libraries (like jquery XML2JSON) 第1步:使用任何一种库(例如jquery XML2JSON)将XML转换为JSON
Step 2 : Select your "DIV" with id with jquery($("#yourid")) and modify the visibility according to the value of the visibility property in your json 第2步:使用jquery($(“#yourid”))选择ID为ID的“ DIV”,并根据json中的visible属性的值修改可见性
(e.g)
if(json[feature].visibility=="hidden")
{
$("#yourid").hide();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.