我的XML以下,我正在使用 vbsript 生成它。

<?xml version="1.0"?>
<tcm:ListItems xmlns:tcm="http://www.tridion.com/ContentManager/5.0" ID="tcm:481-86880-2" Managed="10682">
  <tcm:Item ID="tcm:481-594051"/>
  <tcm:Item ID="tcm:481-594088"/>
  <tcm:Item ID="tcm:481-594089"/>
  <tcm:Item ID="tcm:481-594090"/>
  <tcm:Item ID="tcm:481-594343"/>
  <tcm:Item ID="tcm:481-594344"/>
  <tcm:Item ID="tcm:481-594578"/>
</tcm:ListItems>

现在我有一个pageurl(/english/destinations_offers/destinations/asiapacific/maldives.aspx),将在匹配ID之后显示此示例如下pseudocode

从上方将XML ID匹配,然后我们将添加 pageurl 归因于XML上方。因此,输出将如下:

<?xml version="1.0"?>
<tcm:ListItems xmlns:tcm="http://www.tridion.com/ContentManager/5.0" ID="tcm:481-86880-2" Managed="10682">
  <tcm:Item ID="tcm:481-594051"/>
  <tcm:Item ID="tcm:481-594088"/>
  <tcm:Item ID="tcm:481-594089"/>
  <tcm:Item ID="tcm:481-594090"/>
  <tcm:Item ID="tcm:481-594343" pageURL="/english/destinations_offers/destinations/asiapacific/maldives.aspx"/>
  <tcm:Item ID="tcm:481-594344"/>
  <tcm:Item ID="tcm:481-594578"/>
</tcm:ListItems>

请建议使用vbscript

谢谢。

有帮助吗?

解决方案

这是一个示例 MSXML.

Dim doc
Dim pageUrl
Dim itemNode

Set doc = CreateObject("MSXML2.DOMDocument")
doc.load("test.xml")
doc.setProperty "SelectionNamespaces", "xmlns:tcm='http://www.tridion.com/ContentManager/5.0'"

Set itemNode = doc.selectSingleNode("/tcm:ListItems/tcm:Item[@ID = 'tcm:481-594343']")

Set pageUrl = doc.createAttribute("pageURL") 
pageUrl.Value = "/english/destinations_offers/destinations/asiapacific/maldives.aspx" 
itemNode.attributes.setNamedItem(pageUrl) 

当应用于您提供的XML样品时。它产生以下输出。

<?xml version="1.0"?>
<tcm:ListItems xmlns:tcm="http://www.tridion.com/ContentManager/5.0" ID="tcm:481-86880-2" Managed="10682">
    <tcm:Item ID="tcm:481-594051"/>
    <tcm:Item ID="tcm:481-594088"/>
    <tcm:Item ID="tcm:481-594089"/>
    <tcm:Item ID="tcm:481-594090"/>
    <tcm:Item ID="tcm:481-594343" pageURL="/english/destinations_offers/destinations/asiapacific/maldives.aspx"/>
    <tcm:Item ID="tcm:481-594344"/>
    <tcm:Item ID="tcm:481-594578"/>
</tcm:ListItems>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top