I'm a newbie. I have the following window.members = [
{
LastName: "Test",
FirstName: "Test",
Expires: "2015.01.01"
},
{
LastName: "MacKenzie",
FirstName: "Randy",
Expires: "2019.08.12"
},
{
LastName: "Ahmed",
FirstName: "Jamshed",
Expires: "2017.10.05"
},
{
LastName: "Attaya",
FirstName: "Jim",
Expires: "2018.01.12"
},
];
$(document).ready(function () {
// Create a new date object, it will be the current date.
var today = new Date();
// Set all time components to 0 so the date is at midnight.
today.setHours(0, 0, 0, 0);
// Get a new array with only the members that have an expiration date
// that falls on today or later.
var filteredMembers = window.members.filter(function (members) {
return (new Date(members.Expires).getTime() >= today.getTime());
});
// Initialize the string to hold the HTML to add to the DOM.
var html = "";
// Iterate over all the members that passed the filter.
filteredMembers.forEach(member => {
// Add the HTML for the member to the string.
html += `<div class="members-name">${member.LastName}, ${member.FirstName}</div><div class="members-exp">${member.Expires}</div>`;
});
// Assign the constructed string to the div.
$("div").html(html);
});
:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="div"></div>
How can I display the text in the following format foo = responce.etc('path to your data')
foo = [x.strip() for x in foo]
foo = ''.join(foo)
:
xml
Here is the xsl:
<text>
<sentence type="grocery">I bought <fruit> apples</fruit> at the grocery store.</sentence>
<sentence type="grocery">I also bought <fruit> bananas</fruit> at the store.</sentence>
<sentence>Then, I bought a basket at another store.</sentence>
</text>
Thanks.
答案 0 :(得分:1)
以下样式表:
XSLT 1.0
http://adobe.s3-website-eu-west-1.amazonaws.com
应用于您的示例输入时,将返回:
<强>结果强>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/text">
<html>
<body>
<xsl:apply-templates select="sentence"/>
</body>
</html>
</xsl:template>
<xsl:template match="sentence">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="fruit">
<span style="color:red;">
<xsl:apply-templates/>
</span>
</xsl:template>
</xsl:stylesheet>
呈现为: