1

嗨,这是一个巨大的文件,我需要将元素“AccumulatorFactor”的值更改为元素“价格”

示例:节点 Prepaid2Prepaid 中的价格为 60,因此元素“AccumulatorFactor”也应为 60。

<NodeCopy><Node>SC14
    <Condition>ServiceClass
        <Comment>SC 14 with access fees of 12500 for 30 days</Comment>
        <Values>14</Values>
    </Condition>
    <Node>Community CUG
        <Node>Prepaid2Prepaid
            <Condition>BooleanOperator
                <Operation>AND</Operation>
                <Condition>NumberList
                    <Type>0</Type>
                    <Number>75</Number>
                </Condition>
                <Condition>CommunityId
                    <Value>1-999</Value>
                </Condition>
            </Condition>
            <Tariff>Rate
                <UnitType>Time</UnitType>
                <Price>60.0
                    <Factor>60</Factor>
</Price>
                <Interval>1
                    <Factor>1</Factor>
</Interval>
                <UpdateType>Active</UpdateType>
                <AccumulatorFactor>0.0</AccumulatorFactor>
            </Tariff>
        </Node>
    </Node>
    <Node>A2A
        <Condition>NumberList
            <Type>0</Type>
            <Number>75</Number>
        </Condition>
        <Node>Price
            <Tariff>Rate
                <UnitType>Time</UnitType>
                <Price>163.2
                    <Factor>60</Factor>
</Price>
                <Interval>1
                    <Factor>1</Factor>
</Interval>
                <UpdateType>Active</UpdateType>
                <AccumulatorFactor>0.0</AccumulatorFactor>
            </Tariff>
        </Node>
    </Node>
    <Node>All Operators
        <Condition>NumberList
            <Type>0</Type>
            <Number>77,78
70
76
2911,1108,1177
79
71
3,4,2
121,185,200,91,888,971,2070,890,913,189
555,809</Number>
        </Condition>
        <Node>Price
            <Tariff>Rate
                <UnitType>Time</UnitType>
                <Price>178.8
                    <Factor>60</Factor>
</Price>
                <Interval>1
                    <Factor>1</Factor>
</Interval>
                <UpdateType>Active</UpdateType>
                <AccumulatorFactor>0.0</AccumulatorFactor>
            </Tariff>
        </Node>
    </Node>
</Node>
</NodeCopy>
4

1 回答 1

0
    public void OverWriteXMLElement()
     {
        string AppFileurl = System.Web.HttpContext.Current.Server.MapPath(@"~/Config/GlobalConfig.aspx.cs.xml");
        XmlDocument xDoc = new XmlDocument();
        xDoc.Load(AppFileurl);

        string UserFileurl = System.Web.HttpContext.Current.Server.MapPath(@"~/Config/UserManagement.aspx.cs.xml");
        XmlDocument UserDoc = new XmlDocument();
        UserDoc.Load(UserFileurl);


        XmlNodeList aNodes = xDoc.SelectNodes("/Application/PageSetting/Pagination");
        XmlNodeList UNodes = UserDoc.SelectNodes("/UserManagement/PageSetting/Pagination");

        foreach (XmlNode unode in UNodes)           
        {
            XmlNode child1 = unode.SelectSingleNode("PageSize");

            if (child1.InnerText == "" || child1.InnerText == null)
            {
                foreach (XmlNode node in aNodes)
                {
                    child1.InnerText = node.SelectSingleNode("PageSize").InnerText;
                    UserDoc.Save(UserFileurl);
                }
            }
        }

您可以在另一个 xml 文件的帮助下更改一个 xml 文件的 xml 元素。

于 2014-03-20T06:37:06.907 回答