创建节点

收藏168

阅读1367

更新时间2025-07-30

创建新的元素节点

createElement() 方法创建新的元素节点:

例子 1

newElement = xmlDoc.createElement("edition");

xmlDoc.getElementsByTagName("book")[0].appendChild(newElement);
运行实例 »

点击 "运行实例" 按钮查看在线实例

例子解释:

  1. 假设 books.xml 已被加载到 xmlDoc
  2. 创建一个新的元素节点
  3. 将这个元素节点追加到第一个 元素

例子 2

循环遍历并向所有 元素添加一个元素:

for (i = 0; i < xLen; i++) { 
    newEle = xmlDoc.createElement("edition");
    newText = xmlDoc.createTextNode("第一版");
    newEle.appendChild(newText);
    x[i].appendChild(newEle);
}
运行实例 »

点击 "运行实例" 按钮查看在线实例

创建新的属性节点

createAttribute() 用于创建新的属性节点:

例子 1

newAtt = xmlDoc.createAttribute("edition");
newAtt.nodeValue = "第一版";

xmlDoc.getElementsByTagName("title")[0].setAttributeNode(newAtt);
运行实例 »

点击 "运行实例" 按钮查看在线实例

例子解释:

  1. 假设 books.xml 被加载到 xmlDoc
  2. 创建新的属性节点 "edition"
  3. 将这个属性节点的值设置为 "first"
  4. 将这个新属性节点添加到第一个 元素</li> </ol> <h3>例子 2</h3> <p>循环遍历所有 <title> 元素并添加新的属性节点:</p> <pre class="language-js"> for (i = 0; i < xLen; i++) { newAtt = xmlDoc.createAttribute("edition"); newAtt.value = "第一版"; x[i].setAttributeNode(newAtt); } </pre> <a target="_blank" href="#" class="showbtn codebtn">运行实例 »</a><p>点击 "运行实例" 按钮查看在线实例</p> <p>如果该属性已存在,则将其替换为新属性。</p> <section> <h2>使用 setAttribute() 创建属性</h2> <p>由于 <code>setAttribute()</code> 方法会在属性不存在时创建新属性,因此它也可用于创建新属性。</p> <h3>例子 1</h3> <pre class="language-js"> xmlDoc.getElementsByTagName('book')[0].setAttribute("edition","first"); </pre> <a target="_blank" href="#" class="showbtn codebtn">运行实例 »</a><p>点击 "运行实例" 按钮查看在线实例</p> <h4>例子解释:</h4> <ol> <li>假设 books.xml 已被加载到 <code>xmlDoc</code> 中</li> <li>将第一个 <book> 元素的 <code>"edition"</code> 属性的值设置为 <code>"first"</code></li> </ol> <h3>例子 2</h3> <p>循环遍历所有 <title> 元素并添加新属性:</p> <pre class="language-js"> for(i = 0; i < x.length; i++) { x[i].setAttribute("edition", "第一版"); } </pre> <a target="_blank" href="#" class="showbtn codebtn">运行实例 »</a><p>点击 "运行实例" 按钮查看在线实例</p> <section> <h2>创建文本节点</h2> <p><code>createTextNode()</code> 方法创建新的文本节点:</p> <h3>例子 1</h3> <pre class="language-js"> newEle = xmlDoc.createElement("edition"); newText = xmlDoc.createTextNode("first"); newEle.appendChild(newText); xmlDoc.getElementsByTagName("book")[0].appendChild(newEle); </pre> <a target="_blank" href="#" class="showbtn codebtn">运行实例 »</a><p>点击 "运行实例" 按钮查看在线实例</p> <h4>例子解释:</h4> <ol> <li>假设 books.xml 已被加载到 <code>xmlDoc</code> 中</li> <li>创建新的元素节点 <edition></li> <li>创建新的文本节点,其中包含文本 <code>"first"</code></li> <li>将这个新的文本节点追加到新的元素节点</li> <li>将新元素节点追加到第一个 <book> 元素</li> </ol> <h3>例子 2</h3> <p>将带有文本节点的元素节点添加到所有 <book> 元素:</p> <pre class="language-js"> for (i = 0; i < xLen; i++) { newEle = xmlDoc.createElement("edition"); newText = xmlDoc.createTextNode("第一版"); newEle.appendChild(newText); x[i].appendChild(newEle); } </pre> <a target="_blank" href="#" class="showbtn codebtn">运行实例 »</a><p>点击 "运行实例" 按钮查看在线实例</p> <section> <h2>创建 CDATA Section 节点</h2> <p><code>createCDATASection()</code> 方法创建新的 CDATA section 节点。</p> <h3>例子 1</h3> <pre class="language-js"> newCDATA = xmlDoc.createCDATASection("新年特惠 & 限时折扣"); xmlDoc.getElementsByTagName("book")[0].appendChild(newCDATA); </pre> <a target="_blank" href="#" class="showbtn codebtn">运行实例 »</a><p>点击 "运行实例" 按钮查看在线实例</p> <h4>例子解释:</h4> <ol> <li>假设 books.xml 已被加载到 <code>xmlDoc</code> 中</li> <li>创建新的 CDATA section 节点</li> <li>将这个新的 CDATA 节点追加到第一个 <book> 元素</li> </ol> <h3>例子 2</h3> <p>循环遍历并向所有 <book> 元素添加 CDATA 部分:</p> <pre class="language-js"> x = xmlDoc.getElementsByTagName("book"); xLen = x.length; newtext = "新年特惠 & 限时折扣"; for (i = 0; i < xLen; i++) { newCDATA = xmlDoc.createCDATASection(newtext); x[i].appendChild(newCDATA); } </pre> <a target="_blank" href="#" class="showbtn codebtn">运行实例 »</a><p>点击 "运行实例" 按钮查看在线实例</p> <section> <h2>创建注释节点</h2> <p><code>createComment()</code> 方法创建新的注释节点。</p> <h3>例子 1</h3> <pre class="language-js"> newComment = xmlDoc.createComment("2024 年 2 月修订"); xmlDoc.getElementsByTagName("book")[0].appendChild(newComment); </pre> <a target="_blank" href="#" class="showbtn codebtn">运行实例 »</a><p>点击 "运行实例" 按钮查看在线实例</p> <h4>例子解释:</h4> <ol> <li>假设 books.xml 已被加载到 <code>xmlDoc</code> 中</li> <li>创建新的注释节点</li> <li>将这个新的注释节点追加到第一个 <book> 元素</li> </ol> <h3>例子 2</h3> <p>循环遍历并向所有 <book> 元素添加注释节点:</p> <pre class="language-js"> x = xmlDoc.getElementsByTagName("book"); xLen = x.length for (i = 0; i < xLen; i++) { newComment = xmlDoc.createComment("2024 年 2 月修订"); x[i].appendChild(newComment); } </pre> <a target="_blank" href="#" class="showbtn codebtn">运行实例 »</a><p>点击 "运行实例" 按钮查看在线实例</p> </div> <div class="desadown flexRow"> <a href="/xml/xml-dom-nodes-replace.html" title="替换节点" class="dsdleft flexRow dsda"> <img src="/static/lhimages/icon226.png" class="nocheck"> <img src="/static/lhimages/icon226_check.png" class="check"> <p>替换节点</p> </a> <a href="/xml/xml-dom-nodes-add.html" title="添加节点" class="dsdright flexRow dsda"><p>添加节点</p> <img src="/static/lhimages/icon227.png" class="nocheck"> <img src="/static/lhimages/icon227_check.png" class="check"> </a> </div> </div> <div class="left-video"> <div class="ltzt-title lttitle flexRow"> <div class="title-left flexRow"> <p><span>相关</span><b></b></p> <p>视频</p> <p class="eng">RELATED VIDEOS</p> </div> <a class="title-more flexRow" href="/course/sort_new.html" title="视频教程"><b></b>更多 </a> </div> <div class="video-list flexRow codevideo"> <div class="codevideo-tab flexColumn"> <div class="vtaba-free"> <p>免费</p> </div> <a class="codevtaba flexRow" href="/course/812.html" title="最新ThinkPHP 5.1全球首发视频教程(60天成就PHP大牛线上培训班课)"> <img src="https://img.php.cn/upload/course/000/000/041/620debc3eab3f377.jpg?x-oss-process=image/resize,m_fill,h_150,w_263" alt="最新ThinkPHP 5.1全球首发视频教程(60天成就PHP大牛线上培训班课)" class="codevtabimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="codevtdown flexColumn"> <div> <dt><i class='bg2'>中级</i> <a href="/course/812.html" title="最新ThinkPHP 5.1全球首发视频教程(60天成就PHP大牛线上培训班课)" class="aBlack aClass">最新ThinkPHP 5.1全球首发视频教程(60天成就PHP大牛线上培训班课)</a> </dt> <dd class="flexRow studyandcoll"> <p>1484960次学习</p><em><a class="courseICollection " data-id="812" href="javascript:void(0);"><b></b>收藏</a></em> </dd> </div> </div> </div> <div class="codevideo-tab flexColumn"> <div class="vtaba-free"> <p>免费</p> </div> <a class="codevtaba flexRow" href="/course/1188.html" title="php8,我来也"> <img src="https://img.php.cn/upload/course/000/000/068/62b2ea11e0283309.png?x-oss-process=image/resize,m_fill,h_150,w_263" alt="php8,我来也" class="codevtabimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="codevtdown flexColumn"> <div> <dt><i class='bg1'>初级</i> <a href="/course/1188.html" title="php8,我来也" class="aBlack aClass">php8,我来也</a> </dt> <dd class="flexRow studyandcoll"> <p>315072次学习</p><em><a class="courseICollection " data-id="1188" href="javascript:void(0);"><b></b>收藏</a></em> </dd> </div> </div> </div> <div class="codevideo-tab flexColumn"> <div class="vtaba-free"> <p>免费</p> </div> <a class="codevtaba flexRow" href="/course/1086.html" title="Thinkphp6.0正式版视频教程"> <img src="https://img.php.cn/upload/course/000/000/015/61adbdb9912b0589.png?x-oss-process=image/resize,m_fill,h_150,w_263" alt="Thinkphp6.0正式版视频教程" class="codevtabimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="codevtdown flexColumn"> <div> <dt><i class='bg2'>中级</i> <a href="/course/1086.html" title="Thinkphp6.0正式版视频教程" class="aBlack aClass">Thinkphp6.0正式版视频教程</a> </dt> <dd class="flexRow studyandcoll"> <p>378415次学习</p><em><a class="courseICollection " data-id="1086" href="javascript:void(0);"><b></b>收藏</a></em> </dd> </div> </div> </div> <div class="codevideo-tab flexColumn"> <div class="vtaba-free"> <p>免费</p> </div> <a class="codevtaba flexRow" href="/course/1203.html" title="细说PHP第一季"> <img src="https://img.php.cn/upload/course/000/000/068/6253d15e4bb6a476.png?x-oss-process=image/resize,m_fill,h_150,w_263" alt="细说PHP第一季" class="codevtabimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="codevtdown flexColumn"> <div> <dt><i class='bg2'>中级</i> <a href="/course/1203.html" title="细说PHP第一季" class="aBlack aClass">细说PHP第一季</a> </dt> <dd class="flexRow studyandcoll"> <p>265134次学习</p><em><a class="courseICollection " data-id="1203" href="javascript:void(0);"><b></b>收藏</a></em> </dd> </div> </div> </div> <div class="codevideo-tab flexColumn"> <div class="vtaba-free"> <p>免费</p> </div> <a class="codevtaba flexRow" href="/course/1134.html" title="TP6.0 搭建个人博客实战(玉女心经版)"> <img src="https://img.php.cn/upload/course/000/000/068/62555a16c9bf9556.png?x-oss-process=image/resize,m_fill,h_150,w_263" alt="TP6.0 搭建个人博客实战(玉女心经版)" class="codevtabimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="codevtdown flexColumn"> <div> <dt><i class='bg1'>初级</i> <a href="/course/1134.html" title="TP6.0 搭建个人博客实战(玉女心经版)" class="aBlack aClass">TP6.0 搭建个人博客实战(玉女心经版)</a> </dt> <dd class="flexRow studyandcoll"> <p>208023次学习</p><em><a class="courseICollection " data-id="1134" href="javascript:void(0);"><b></b>收藏</a></em> </dd> </div> </div> </div> <div class="codevideo-tab flexColumn"> <div class="vtaba-free"> <p>免费</p> </div> <a class="codevtaba flexRow" href="/course/1503.html" title="简单聊聊PHP创业那点事"> <img src="https://img.php.cn/upload/course/000/000/067/64be3549bab29833.png?x-oss-process=image/resize,m_fill,h_150,w_263" alt="简单聊聊PHP创业那点事" class="codevtabimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="codevtdown flexColumn"> <div> <dt><i class='bg1'>初级</i> <a href="/course/1503.html" title="简单聊聊PHP创业那点事" class="aBlack aClass">简单聊聊PHP创业那点事</a> </dt> <dd class="flexRow studyandcoll"> <p>12919次学习</p><em><a class="courseICollection " data-id="1503" href="javascript:void(0);"><b></b>收藏</a></em> </dd> </div> </div> </div> <div class="codevideo-tab flexColumn"> <div class="vtaba-free"> <p>免费</p> </div> <a class="codevtaba flexRow" href="/course/797.html" title="PHP实战天龙八部之微信支付视频教程"> <img src="https://img.php.cn/upload/course/000/000/001/5d242759adb88970.jpg?x-oss-process=image/resize,m_fill,h_150,w_263" alt="PHP实战天龙八部之微信支付视频教程" class="codevtabimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="codevtdown flexColumn"> <div> <dt><i class='bg2'>中级</i> <a href="/course/797.html" title="PHP实战天龙八部之微信支付视频教程" class="aBlack aClass">PHP实战天龙八部之微信支付视频教程</a> </dt> <dd class="flexRow studyandcoll"> <p>171999次学习</p><em><a class="courseICollection " data-id="797" href="javascript:void(0);"><b></b>收藏</a></em> </dd> </div> </div> </div> <div class="codevideo-tab flexColumn"> <div class="vtaba-free"> <p>免费</p> </div> <a class="codevtaba flexRow" href="/course/801.html" title="PHP实战天龙八部之仿爱奇艺电影网站"> <img src="https://img.php.cn/upload/course/000/000/001/5d2426f409839992.jpg?x-oss-process=image/resize,m_fill,h_150,w_263" alt="PHP实战天龙八部之仿爱奇艺电影网站" class="codevtabimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="codevtdown flexColumn"> <div> <dt><i class='bg2'>中级</i> <a href="/course/801.html" title="PHP实战天龙八部之仿爱奇艺电影网站" class="aBlack aClass">PHP实战天龙八部之仿爱奇艺电影网站</a> </dt> <dd class="flexRow studyandcoll"> <p>769630次学习</p><em><a class="courseICollection " data-id="801" href="javascript:void(0);"><b></b>收藏</a></em> </dd> </div> </div> </div> <div class="codevideo-tab flexColumn"> <div class="vtaba-free"> <p>免费</p> </div> <a class="codevtaba flexRow" href="/course/836.html" title="大型实战天龙八部之开发Mini版MVC框架仿糗事百科网站"> <img src="https://img.php.cn/upload/course/000/000/001/5d24230536122573.jpg?x-oss-process=image/resize,m_fill,h_150,w_263" alt="大型实战天龙八部之开发Mini版MVC框架仿糗事百科网站" class="codevtabimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="codevtdown flexColumn"> <div> <dt><i class='bg2'>中级</i> <a href="/course/836.html" title="大型实战天龙八部之开发Mini版MVC框架仿糗事百科网站" class="aBlack aClass">大型实战天龙八部之开发Mini版MVC框架仿糗事百科网站</a> </dt> <dd class="flexRow studyandcoll"> <p>43815次学习</p><em><a class="courseICollection " data-id="836" href="javascript:void(0);"><b></b>收藏</a></em> </dd> </div> </div> </div> </div> </div> </div> </div> <div class="conRight"> <div class="technology-news rightDiv"> <div class="rightdTitle flexRow"> <div class="title-left flexRow"> <b></b> <p>科技资讯</p> </div> <a class="rititle-more flexRow" href="/it" title="科技资讯">更多</a> </div> <ul class="tecnewul"> <li class="tecnelli flexRow"> <a href="/faq/1793681.html" title="闻泰科技:敦促安世荷兰正视问题,共同守护产业链稳定" class="tecna"> <img src="https://img.php.cn/upload/article/001/246/273/176439564577107.jpg?x-oss-process=image/resize,m_fill,h_88,w_162" alt="闻泰科技:敦促安世荷兰正视问题,共同守护产业链稳定" class="tecnAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="tecnRight flexColumn"> <a href="/faq/1793681.html" title="闻泰科技:敦促安世荷兰正视问题,共同守护产业链稳定" class="tecnda overflowclass">闻泰科技:敦促安世荷兰正视问题,共同守护产业链稳定</a> <a class="tecnp overflowclass" href="/faq/1793681.html" title="闻泰科技:敦促安世荷兰正视问题,共同守护产业链稳定">感谢网友Roronoa_、西窗旧事提供的线索!11月28日消息,今日,闻泰科技就安世半导体控制权争端及其对全球芯片产业链的影响发布官方声明。声明全文如下:一、非法剥夺闻泰科技股东权利是引发全球供应链动荡的根源我们注意到,安世荷兰于11月27日向安世中国管理层发布的公开信中包含大量不实信息与误导性言论,暴露出其推卸责任、回避核心矛盾的态度,也反映出其在解决当前危机方面缺乏诚意。正如中国商务部所明确指出,此次全球半导体供应链紊乱的源头在于荷兰方面。正是由于荷兰经济部的不当介入,安世荷兰通过企业法庭发</a> </div> </li> <li class="tecnelli flexRow"> <a href="/faq/1793534.html" title="不只内存涨价,消息称松下部分钽电容型号价格上涨 15~30%" class="tecna"> <img src="https://img.php.cn/upload/article/001/246/273/176439339984181.png?x-oss-process=image/resize,m_fill,h_88,w_162" alt="不只内存涨价,消息称松下部分钽电容型号价格上涨 15~30%" class="tecnAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="tecnRight flexColumn"> <a href="/faq/1793534.html" title="不只内存涨价,消息称松下部分钽电容型号价格上涨 15~30%" class="tecnda overflowclass">不只内存涨价,消息称松下部分钽电容型号价格上涨 15~30%</a> <a class="tecnp overflowclass" href="/faq/1793534.html" title="不只内存涨价,消息称松下部分钽电容型号价格上涨 15~30%">11月28日消息,在全球超大规模计算企业加速推进AI服务器数据中心建设的背景下,内存并非唯一面临供应压力的关键元件。据台媒《工商时报》今日报道,继多家美国厂商上调价格后,日本厂商也开始跟进,日本松下(Panasonic)已正式通知经销商与客户,部分钽电容产品将调涨价格15~30%。此次涨价为松下在2025年内的首次调整,此前该公司已于2024年12月实施过一轮提价。本次价格变动涉及约30至40种钽聚合物电容型号,将于2026年2月1日起正式生效,主要目的是应对原</a> </div> </li> <li class="tecnelli flexRow"> <a href="/faq/1792988.html" title="消息称三星显示将现有团队升级为办公室,以更高效率响应苹果需求" class="tecna"> <img src="https://img.php.cn/upload/article/001/246/273/176438589775125.png?x-oss-process=image/resize,m_fill,h_88,w_162" alt="消息称三星显示将现有团队升级为办公室,以更高效率响应苹果需求" class="tecnAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="tecnRight flexColumn"> <a href="/faq/1792988.html" title="消息称三星显示将现有团队升级为办公室,以更高效率响应苹果需求" class="tecnda overflowclass">消息称三星显示将现有团队升级为办公室,以更高效率响应苹果需求</a> <a class="tecnp overflowclass" href="/faq/1792988.html" title="消息称三星显示将现有团队升级为办公室,以更高效率响应苹果需求">11月28日消息,苹果正加速推进多条核心产品线的研发进程,三星在其中的重要性日益凸显,尤其是在即将与iPhone18系列一同发布的折叠屏机型iPhoneFold上合作紧密。随着越来越多的苹果设备采用三星技术,最新消息称,三星显示已全面重组其团队架构,以更高效地响应苹果的需求。据韩媒TheElec今日报道,三星显示已将原属“A事业部”的研发与销售团队进行拆分:A-DevelopmentTeam(开发团队)正式升级为A-DevelopmentOffice(开发办公室),而销售职</a> </div> </li> </ul> </div> <div class="readCharts"> <div class="readDown flexColumn"> <div class="rightdTitle flexRow"> <div class="title-left flexRow"> <b></b><b></b></div> <a class="rititle-more flexRow" href="/article.html" target="_blank" title="更多">更多</a> </div> <ul class="rcUl"> <li class="rcLi flexRow"> <div class="rclileft"> <p>1</p> </div> <div class="flexColumn rcreadDiv"> <a href="/faq/1793824.html" class=" aClass readA overflowclass" title="JavaScript异步操作:将全局变量正确初始化为Promise的实践">JavaScript异步操作:将全局变量正确初始化为Promise的实践</a> <a href="/faq/1793824.html" class=" aClass overflowclass" title="JavaScript异步操作:将全局变量正确初始化为Promise的实践">本教程深入探讨JavaScript中处理异步操作的关键技术,特别是如何确保全局变量正确接收并管理Promise类型的结果。我们将通过分析常见错误,讲解async/await的正确用法,以及如何将异步函数的返回值(Promise)有效赋值给全局变量,从而避免undefined错误,确保数据流的稳定性和可预测性。</a> </div> </li> <li class="rcLi flexRow"> <div class="rclileft"> <p>2</p> </div> <div class="flexColumn rcreadDiv"> <a href="/faq/1793820.html" class=" aClass readA overflowclass" title="Go Reflection深度解析:如何访问被遮蔽的嵌入式结构体方法">Go Reflection深度解析:如何访问被遮蔽的嵌入式结构体方法</a> </div> </li> <li class="rcLi flexRow"> <div class="rclileft"> <p>3</p> </div> <div class="flexColumn rcreadDiv"> <a href="/faq/1793814.html" class=" aClass readA overflowclass" title="如何安装Go移动端开发环境_Go移动端交叉编译环境配置说明">如何安装Go移动端开发环境_Go移动端交叉编译环境配置说明</a> </div> </li> <li class="rcLi flexRow"> <div class="rclileft"> <p>4</p> </div> <div class="flexColumn rcreadDiv"> <a href="/faq/1793812.html" class=" aClass readA overflowclass" title="Angular Electron 应用空闲屏保实现指南">Angular Electron 应用空闲屏保实现指南</a> </div> </li> <li class="rcLi flexRow"> <div class="rclileft"> <p>5</p> </div> <div class="flexColumn rcreadDiv"> <a href="/faq/1793810.html" class=" aClass readA overflowclass" title="如何在CSS中使用Bootstrap制作响应式图片_Bootstrap img-fluid类控制自适应">如何在CSS中使用Bootstrap制作响应式图片_Bootstrap img-fluid类控制自适应</a> </div> </li> <li class="rcLi flexRow"> <div class="rclileft"> <p>6</p> </div> <div class="flexColumn rcreadDiv"> <a href="/faq/1793811.html" class=" aClass readA overflowclass" title="处理嵌套交互式控件:解决可访问性警告与最佳实践">处理嵌套交互式控件:解决可访问性警告与最佳实践</a> </div> </li> <li class="rcLi flexRow"> <div class="rclileft"> <p>7</p> </div> <div class="flexColumn rcreadDiv"> <a href="/faq/1793808.html" class=" aClass readA overflowclass" title="解决嵌套交互式控件的无障碍性问题:以可点击表格行内复选框为例">解决嵌套交互式控件的无障碍性问题:以可点击表格行内复选框为例</a> </div> </li> <li class="rcLi flexRow"> <div class="rclileft"> <p>8</p> </div> <div class="flexColumn rcreadDiv"> <a href="/faq/1793800.html" class=" aClass readA overflowclass" title="Golang如何测试缓存并发安全_Golang 并发缓存安全性测试实践">Golang如何测试缓存并发安全_Golang 并发缓存安全性测试实践</a> </div> </li> <li class="rcLi flexRow"> <div class="rclileft"> <p>9</p> </div> <div class="flexColumn rcreadDiv"> <a href="/faq/1793799.html" class=" aClass readA overflowclass" title="Go语言浮点数精度详解:float32与float64的差异及应用陷阱">Go语言浮点数精度详解:float32与float64的差异及应用陷阱</a> </div> </li> </ul> </div> </div> <div class="adversitement"> <script type="text/javascript" src="https://teacher.php.cn/php/MDM3MTk1MGYxYjI5ODJmNTE0ZWVkZTA3NmJhYzhmMjI6Og=="></script> </div> <div class=" rightStudy rightDiv"> <div class="rightdTitle flexRow"> <div class="title-left flexRow"> <b></b> <p> 精选课程</p> </div> <a class="rititle-more flexRow" href="/course/sort_new.html" title="精选课程">更多</a> </div> <div class="ristyList flexColumn"> <div class="ristyA flexRow "> <a href="/course/797.html" title="PHP实战天龙八部之微信支付视频教程"> <img src="https://img.php.cn/upload/course/000/000/001/5d242759adb88970.jpg?x-oss-process=image/resize,m_fill,h_88,w_162" alt="PHP实战天龙八部之微信支付视频教程" class="ristyAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ristyaRight flexColumn"> <a href="/course/797.html" title="PHP实战天龙八部之微信支付视频教程" class="rirightp overflowclass">PHP实战天龙八部之微信支付视频教程</a> <div class="risrdown flexRow"> <p>共5课时</p><b></b> <p>17.2万人学习</p> </div> </div> </div> <div class="ristyA flexRow "> <a href="/course/801.html" title="PHP实战天龙八部之仿爱奇艺电影网站"> <img src="https://img.php.cn/upload/course/000/000/001/5d2426f409839992.jpg?x-oss-process=image/resize,m_fill,h_88,w_162" alt="PHP实战天龙八部之仿爱奇艺电影网站" class="ristyAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ristyaRight flexColumn"> <a href="/course/801.html" title="PHP实战天龙八部之仿爱奇艺电影网站" class="rirightp overflowclass">PHP实战天龙八部之仿爱奇艺电影网站</a> <div class="risrdown flexRow"> <p>共49课时</p><b></b> <p>77.2万人学习</p> </div> </div> </div> <div class="ristyA flexRow "> <a href="/course/880.html" title="前端入门_HTML5"> <img src="https://img.php.cn/upload/course/000/000/068/6255589398c2c999.png?x-oss-process=image/resize,m_fill,h_88,w_162" alt="前端入门_HTML5" class="ristyAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ristyaRight flexColumn"> <a href="/course/880.html" title="前端入门_HTML5" class="rirightp overflowclass">前端入门_HTML5</a> <div class="risrdown flexRow"> <p>共29课时</p><b></b> <p>61.9万人学习</p> </div> </div> </div> <div class="ristyA flexRow "> <a href="/course/893.html" title="CSS视频教程-玉女心经版"> <img src="https://img.php.cn/upload/course/000/000/068/625558b87e512730.png?x-oss-process=image/resize,m_fill,h_88,w_162" alt="CSS视频教程-玉女心经版" class="ristyAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ristyaRight flexColumn"> <a href="/course/893.html" title="CSS视频教程-玉女心经版" class="rirightp overflowclass">CSS视频教程-玉女心经版</a> <div class="risrdown flexRow"> <p>共25课时</p><b></b> <p>39.4万人学习</p> </div> </div> </div> <div class="ristyA flexRow "> <a href="/course/894.html" title="JavaScript极速入门_玉女心经系列"> <img src="https://img.php.cn/upload/course/000/000/068/625558e4f11c8518.png?x-oss-process=image/resize,m_fill,h_88,w_162" alt="JavaScript极速入门_玉女心经系列" class="ristyAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ristyaRight flexColumn"> <a href="/course/894.html" title="JavaScript极速入门_玉女心经系列" class="rirightp overflowclass">JavaScript极速入门_玉女心经系列</a> <div class="risrdown flexRow"> <p>共43课时</p><b></b> <p>71.1万人学习</p> </div> </div> </div> <div class="ristyA flexRow "> <a href="/course/372.html" title="独孤九贱(1)_HTML5视频教程"> <img src="https://img.php.cn/upload/course/000/000/001/5d1c6ddbecdb1707.jpg?x-oss-process=image/resize,m_fill,h_88,w_162" alt="独孤九贱(1)_HTML5视频教程" class="ristyAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ristyaRight flexColumn"> <a href="/course/372.html" title="独孤九贱(1)_HTML5视频教程" class="rirightp overflowclass">独孤九贱(1)_HTML5视频教程</a> <div class="risrdown flexRow"> <p>共25课时</p><b></b> <p>61.8万人学习</p> </div> </div> </div> <div class="ristyA flexRow "> <a href="/course/373.html" title="独孤九贱(2)_CSS视频教程"> <img src="https://img.php.cn/upload/course/000/000/001/5d1c6de7424b9255.jpg?x-oss-process=image/resize,m_fill,h_88,w_162" alt="独孤九贱(2)_CSS视频教程" class="ristyAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ristyaRight flexColumn"> <a href="/course/373.html" title="独孤九贱(2)_CSS视频教程" class="rirightp overflowclass">独孤九贱(2)_CSS视频教程</a> <div class="risrdown flexRow"> <p>共22课时</p><b></b> <p>23万人学习</p> </div> </div> </div> <div class="ristyA flexRow "> <a href="/course/386.html" title="独孤九贱(3)_JavaScript视频教程"> <img src="https://img.php.cn/upload/course/000/000/001/5d1c6df423564706.jpg?x-oss-process=image/resize,m_fill,h_88,w_162" alt="独孤九贱(3)_JavaScript视频教程" class="ristyAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ristyaRight flexColumn"> <a href="/course/386.html" title="独孤九贱(3)_JavaScript视频教程" class="rirightp overflowclass">独孤九贱(3)_JavaScript视频教程</a> <div class="risrdown flexRow"> <p>共28课时</p><b></b> <p>34万人学习</p> </div> </div> </div> <div class="ristyA flexRow "> <a href="/course/379.html" title="独孤九贱(4)_PHP视频教程"> <img src="https://img.php.cn/upload/course/000/000/001/5d1c6dfc9eb09885.jpg?x-oss-process=image/resize,m_fill,h_88,w_162" alt="独孤九贱(4)_PHP视频教程" class="ristyAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ristyaRight flexColumn"> <a href="/course/379.html" title="独孤九贱(4)_PHP视频教程" class="rirightp overflowclass">独孤九贱(4)_PHP视频教程</a> <div class="risrdown flexRow"> <p>共89课时</p><b></b> <p>125.5万人学习</p> </div> </div> </div> </div> </div> <div class=" rightDowns rightDiv"> <div class="rightdTitle flexRow"> <div class="title-left flexRow"> <b></b> <p> 热门下载</p> </div> <a class="rititle-more flexRow" href="/xiazai/" title="热门下载">更多</a> </div> <div class="rids"> <div href="/xiazai/gongju/845" title="phpStudy 2018最新版" class="ridsA flexRow " > <a href="/xiazai/gongju/845" title="phpStudy 2018最新版"> <img src="https://img.php.cn/upload/manual/000/000/001/5a5f0fb612676526.jpg?x-oss-process=image/resize,m_fill,h_60,w_101" alt="phpStudy 2018最新版" class="ridsAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ridsaRight flexColumn"> <a href="/xiazai/gongju/845" title="phpStudy 2018最新版" class="ridsrp overflowclass">phpStudy 2018最新版</a> <a class="ridsrdown flexRow" href="/xiazai/gongju/845" title="phpStudy 2018最新版"> <p>下载</p> </a> </div> </div> <div href="/xiazai/gongju/1351" title="vc9-vc14(32+64位)运行库合集(链接在下方)" class="ridsA flexRow " > <a href="/xiazai/gongju/1351" title="vc9-vc14(32+64位)运行库合集(链接在下方)"> <img src="https://img.php.cn/upload/manual/000/000/001/5a6a896b53dea437.png?x-oss-process=image/resize,m_fill,h_60,w_101" alt="vc9-vc14(32+64位)运行库合集(链接在下方)" class="ridsAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ridsaRight flexColumn"> <a href="/xiazai/gongju/1351" title="vc9-vc14(32+64位)运行库合集(链接在下方)" class="ridsrp overflowclass">vc9-vc14(32+64位)运行库合集(链接在下方)</a> <a class="ridsrdown flexRow" href="/xiazai/gongju/1351" title="vc9-vc14(32+64位)运行库合集(链接在下方)"> <p>下载</p> </a> </div> </div> <div href="/xiazai/gongju/1479" title="VC9 32位" class="ridsA flexRow " > <a href="/xiazai/gongju/1479" title="VC9 32位"> <img src="https://img.php.cn/upload/manual/000/000/001/5af2c4207a616756.jpg?x-oss-process=image/resize,m_fill,h_60,w_101" alt="VC9 32位" class="ridsAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ridsaRight flexColumn"> <a href="/xiazai/gongju/1479" title="VC9 32位" class="ridsrp overflowclass">VC9 32位</a> <a class="ridsrdown flexRow" href="/xiazai/gongju/1479" title="VC9 32位"> <p>下载</p> </a> </div> </div> <div href="/xiazai/gongju/1481" title="VC11 32位" class="ridsA flexRow " > <a href="/xiazai/gongju/1481" title="VC11 32位"> <img src="https://img.php.cn/upload/manual/000/000/001/5af2c4684dbe4408.jpg?x-oss-process=image/resize,m_fill,h_60,w_101" alt="VC11 32位" class="ridsAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ridsaRight flexColumn"> <a href="/xiazai/gongju/1481" title="VC11 32位" class="ridsrp overflowclass">VC11 32位</a> <a class="ridsrdown flexRow" href="/xiazai/gongju/1481" title="VC11 32位"> <p>下载</p> </a> </div> </div> <div href="/xiazai/gongju/714" title="php程序员工具箱完整版" class="ridsA flexRow " > <a href="/xiazai/gongju/714" title="php程序员工具箱完整版"> <img src="https://img.php.cn/upload/manual/000/000/001/5a718c0e5be0a511.jpg?x-oss-process=image/resize,m_fill,h_60,w_101" alt="php程序员工具箱完整版" class="ridsAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ridsaRight flexColumn"> <a href="/xiazai/gongju/714" title="php程序员工具箱完整版" class="ridsrp overflowclass">php程序员工具箱完整版</a> <a class="ridsrdown flexRow" href="/xiazai/gongju/714" title="php程序员工具箱完整版"> <p>下载</p> </a> </div> </div> <div href="/xiazai/gongju/1484" title="VC14 32位" class="ridsA flexRow " > <a href="/xiazai/gongju/1484" title="VC14 32位"> <img src="https://img.php.cn/upload/manual/000/000/001/5af2c54fc1f91550.jpg?x-oss-process=image/resize,m_fill,h_60,w_101" alt="VC14 32位" class="ridsAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ridsaRight flexColumn"> <a href="/xiazai/gongju/1484" title="VC14 32位" class="ridsrp overflowclass">VC14 32位</a> <a class="ridsrdown flexRow" href="/xiazai/gongju/1484" title="VC14 32位"> <p>下载</p> </a> </div> </div> <div href="/xiazai/gongju/93" title="SublimeText3汉化版" class="ridsA flexRow " > <a href="/xiazai/gongju/93" title="SublimeText3汉化版"> <img src="https://img.php.cn/upload/manual/000/000/001/58a1753774be3478.png?x-oss-process=image/resize,m_fill,h_60,w_101" alt="SublimeText3汉化版" class="ridsAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ridsaRight flexColumn"> <a href="/xiazai/gongju/93" title="SublimeText3汉化版" class="ridsrp overflowclass">SublimeText3汉化版</a> <a class="ridsrdown flexRow" href="/xiazai/gongju/93" title="SublimeText3汉化版"> <p>下载</p> </a> </div> </div> <div href="/xiazai/gongju/92" title="Notepad++7.3.1" class="ridsA flexRow " > <a href="/xiazai/gongju/92" title="Notepad++7.3.1"> <img src="https://img.php.cn/upload/manual/000/000/001/58a1713812af3871.png?x-oss-process=image/resize,m_fill,h_60,w_101" alt="Notepad++7.3.1" class="ridsAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ridsaRight flexColumn"> <a href="/xiazai/gongju/92" title="Notepad++7.3.1" class="ridsrp overflowclass">Notepad++7.3.1</a> <a class="ridsrdown flexRow" href="/xiazai/gongju/92" title="Notepad++7.3.1"> <p>下载</p> </a> </div> </div> <div href="/xiazai/gongju/1500" title="phpStudy V8.1(Win64位)(已支持php8)" class="ridsA flexRow " > <a href="/xiazai/gongju/1500" title="phpStudy V8.1(Win64位)(已支持php8)"> <img src="https://img.php.cn/upload/manual/000/000/001/5eb23582ba149960.png?x-oss-process=image/resize,m_fill,h_60,w_101" alt="phpStudy V8.1(Win64位)(已支持php8)" class="ridsAimg" onerror="this.src='/static/lhimages/moren/morentu.png'"> </a> <div class="ridsaRight flexColumn"> <a href="/xiazai/gongju/1500" title="phpStudy V8.1(Win64位)(已支持php8)" class="ridsrp overflowclass">phpStudy V8.1(Win64位)(已支持php8)</a> <a class="ridsrdown flexRow" href="/xiazai/gongju/1500" title="phpStudy V8.1(Win64位)(已支持php8)"> <p>下载</p> </a> </div> </div> </div> </div> </div> </div> </div> <!--底部--> <div class="phpFoot"> <div class="phpFootIn"> <div class="phpFootCont"> <div class="phpFootLeft"> <dl> <dt> <a href="/about/us.html" rel="nofollow" target="_blank" title="关于我们" class="cBlack">关于我们</a> <a href="/about/disclaimer.html" rel="nofollow" target="_blank" title="免责申明" class="cBlack">免责申明</a> <a href="/about/jbzx.html" rel="nofollow" target="_blank" title="举报中心" class="cBlack">举报中心</a> <a href="javascript:;" rel="nofollow" onclick="advice_data(99999999,'意见反馈')" title="意见反馈" class="cBlack">意见反馈</a> <a href="https://www.php.cn/teacher.html" rel="nofollow" target="_blank" title="讲师合作" class="cBlack">讲师合作</a> <a href="https://www.php.cn/blog/detail/20304.html" rel="nofollow" target="_blank" title="广告合作" class="cBlack">广告合作</a> <!--<a href="javascript:;" target="_blank" title="其他合作" class="cBlack">其他合作</a>--> <a href="/new/" target="_blank" title="最新文章列表" class="cBlack">最新更新</a> <a href="https://global.php.cn/" target="_blank" title="English" class="cBlack">English</a> <div class="clear"></div> </dt> <dd class="cont1">php中文网:公益在线php培训,帮助PHP学习者快速成长!</dd> <dd class="cont2"> <span class="ylwTopBox"> <a href="javascript:;" class="cBlack"><b class="icon1"></b>关注服务号</a> <em style="display:none;" class="ylwTopSub"> <p>微信扫码<br/>关注PHP中文网服务号</p> <img src="/static/images/examples/text16.png"/> </em> </span> <span class="ylwTopBox"> <a href="tencent://message/?uin=27220243&Site=www.php.cn&Menu=yes" target="_blank" class="cBlack"><b class="icon2"></b>技术交流群</a> <em style="display:none;" class="ylwTopSub"> <p>QQ扫码<br/>加入技术交流群</p> <img src="/static/images/examples/text18.png"/> </em> </span> <div class="clear"></div> </dd> </dl> </div> <div class="phpFootRight"> <div class="phpFootMsg"> <span><img src="/static/images/examples/text17.png"/></span> <dl> <dt>PHP中文网订阅号</dt> <dd>每天精选资源文章推送</dd> </dl> </div> <div class="phpFootMsg"> <span><img src="/static/images/examples/text14.png"/></span> <dl> <dt>PHP中文网APP</dt> <dd>随时随地碎片化学习</dd> </dl> </div> </div> </div> </div> <div class="phpFootCode"> <div class="phpFootCodeIn"><p>Copyright 2014-2025 <a href="https://www.php.cn/" target="_blank">https://www.php.cn/</a> All Rights Reserved | php.cn | <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">湘ICP备2023035733号</a></p><a href="http://www.beian.gov.cn/portal/index.do" rel="nofollow" target="_blank"><b></b></a></div> </div> </div> <input type="hidden" id="verifycode" value="/captcha.html"> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?c0e685c8743351838d2a7db1c49abd56"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <script>layui.use(['element', 'carousel'], function () {var element = layui.element;$ = layui.jquery;var carousel = layui.carousel;carousel.render({elem: '#test1', width: '100%', height: '330px', arrow: 'always'});$.getScript('/static/js/jquery.lazyload.min.js', function () {$("img").lazyload({placeholder: "/static/images/load.jpg", effect: "fadeIn", threshold: 200, skip_invisible: false});});});</script> <span class="layui-hide"><script type="text/javascript" src="https://s4.cnzz.com/z_stat.php?id=1280886301&web_id=1280886301"></script></span> <!--底部 end--> <script type="text/javascript" src="/static/js/global.min.js?5.5.53"></script> <script src="/static/ueditor/third-party/SyntaxHighlighter/shCore.js"></script> <script src="/static/js/CodeRunOnline.js?3.1"></script> <script>var _hmt = _hmt || [];(function(){var hm = document.createElement("script");hm.src="//hm.baidu.com/hm.js?aaf8dba0861f46190106021371583c62";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(hm, s);})();(function(){var bp = document.createElement('script');var curProtocol = window.location.protocol.split(':')[0];if(curProtocol === 'https'){bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';}else{bp.src = 'http://push.zhanzhang.baidu.com/push.js';};var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(bp, s);})();</script> </body> <script> function copyCurrentUrl() { const url = window.location.href; const input = document.createElement('input'); input.value = url; document.body.appendChild(input); input.select(); document.execCommand('copy'); document.body.removeChild(input); alert('✅ 已复制当前链接:' + url); } </script> </html>