0
<ce_table frame="topbot" id="t0010" rowsep="0" colsep="0">   
    <ce_label>Table 2</ce_label> 
        <ce_caption id="cn040"> 
            <ce_simple-para id="spar055">Model fit cnbs for the span targeted moments.</ce_simple-para> 
        </ce_caption>
    </ce_label>  
</ce_table>

I need to change id="t0010" to id="tf0010" and id="cn.. " to id="cib.. ".

I only need to change prefix of an attribute value.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

Use xml linq :

using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);
            XElement ce_table = doc.Descendants("ce_table").First();
            ce_table.SetAttributeValue("id", "tf0010");
            XElement ce_caption = ce_table.Descendants("ce_caption").First();
            ce_caption.SetAttributeValue("id", "cib040");
 


        }
 
    }
 
}
jdweng
  • 33,250
  • 2
  • 15
  • 20