I have different Xml strings that can contain one or more parts in the following format:
47862656
The valu
You shouldn't use regex to manipulate XML, they're not the appropriate tool for that and won't always work. For instance, the XML file could use a namespace prefix other than ns1
, mapped to the same namespace, and it would be semantically equivalent, but your regex wouldn't work anymore.
You should use an XML parser instead; the easiest to use is Linq to XML:
var doc = XDocument.Parse(Xml);
var ns1 = XNamespace.Get("http://TheNamespaceMappedToTheNs1Prefix");
var elements = doc.Descendants(ns1 + "AcctId");
foreach (var e in elements)
{
e.Value = IBANHelper.ConvertBBANToIBAN(e.Value);
}
Xml = doc.ToString();