我正在尝试使用其id属性
在我已定位的元素中编写新元素这是XML:
<?xml version="1.0" encoding="UTF-8"?>
<webpages>
<course id="fteCharts">
<linkName>FTE Charts</linkName>
<link>index.cfm</link>
<linkInfo>Looking for a new job or rotational experience, the links to NRC Jobs, solicitations of interest and rotational opportunities are provided. Would you like to become a leader in the NRC. The NRC offers a number of leadership development programs. The Leadership Development link provides you a list of these programs.</linkInfo>
</course>
<course id="matrix">
<linkName>Skills Matrix</linkName>
<link>index.cfm</link>
<linkInfo>Skills Matrix Link. The NRC offers a number of leadership development programs. The Leadership Development link provides you a list of these programs.</linkInfo>
<subLink>
<name>Adminstrator Tool Kit 2</name>
<url>http://r2.nrc.gov/drs/careertools/admintoolkit.pdf</url>
</subLink>
<subLink>
<name>Technical Tool Kit Matrix 2</name>
<url>http://r2.nrc.gov/drs/careertools/technicaltoolkit.pdf</url>
</subLink>
</course>
</webpages>
以下是我在cfc中提取此元素的数据:
<cfset params = toString( getHttpRequestData().content ) />
<cfset args = #deserializeJSON(params)# />
<cfset bPath = "e:\webapps\NRCNewsApps\rmsi" />
<cffile action="read" file="#bPath#\xml\nav.xml" variable="myxml">
<cfset thedoc = XmlParse(myxml)>
<cfset arynode = XmlSearch(thedoc, "/webpages/course[ @id = '#args.linkID#' ]") />
<cfset xmlCourse = arynode[1] />
所以xmlCourse
然后返回我想要添加节点的课程。它是一个包含我需要的xml数据的数组:
XmlElemNew(xmlCourse, "subLink");
我想在目标课程中创建新的空白xml节点(名为“sublink”),我一整天都在尝试并且没有想到它。
答案 0 :(得分:0)
您必须将xml文件保存到ram或磁盘中,然后读取它并搜索保存的文档并通过读取数据并使用file和append命令附加节点来附加节点。我不确定你为什么要插入空节点。你想达到什么目的?但也有CFC文件也会读取xml并将其转换为我之前使用过的结构,但从未找到任何真正的实际应用程序使用它。