使用正则表达式使用其他文本附加XML元素的值

时间:2016-03-02 01:32:44

标签: regex xml c#-4.0 rdl

我正在尝试在XML中转换以下内容

<SharedDataSetReference>AnyDataSetName</SharedDataSetReference>

<SharedDataSetReference>/DataSets/AnyDataSetName</SharedDataSetReference>

同时,

的现有实例
<SharedDataSetReference>/DataSets/AnyDataSetName</SharedDataSetReference>

应保持不变。

请注意AnyDataSetName可以有

<SharedDataSetReference>Company</SharedDataSetReference>
<SharedDataSetReference>Customer</SharedDataSetReference>

或     /数据集/顺序

他们应该改为

<SharedDataSetReference>/Datasets/Company</SharedDataSetReference>
<SharedDataSetReference>/Datasets/Customer</SharedDataSetReference>
<SharedDataSetReference>/Datasets/Order</SharedDataSetReference>

2 个答案:

答案 0 :(得分:1)

试试这个

<SharedDataSetReference>([^\/]+)<\/SharedDataSetReference>

https://regex101.com/r/yM7tA0/1

答案 1 :(得分:0)

谢谢Tim007 这就是我所做的

SELECT TOP 1