简体   繁体   中英

Move XML element using XDT

Is there a way to move an XML element, including all of its content, inside another element using XDT?

For example, I'd like to transform the following XML:

<?xml version="1.0"?>
<a>
    <b someAttribute="someValue">someContent</b>
</a>

into this:

<?xml version="1.0"?>
<a>
    <c>
        <b someAttribute="someValue">someContent</b>
    </c>
</a>

by moving the b element inside of the newly created c element. I was hoping that something like the following would work:

<?xml version="1.0"?>
<a xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <c xdt:Transform="Insert">
        <b xdt:Locator="XPath(/a/b)" xdt:Transform="an appropriate transform" />
    </c>
</a>

But AFAIK there is no transform that would do this.

目前不支持此功能,如Web.config转换-周围的元素中所述 ,但此问题确实提供了一种解决方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM