Hi Guys,
I am trying to modify an xml string on the fly. I will enter a sample XML string and the code should generate modified xml.I have exploied it later.
xml = xml = '''<FixedPage xmlns="http://schemas.microsoft.com/xps/2005/06" xmlns:x="http://schemas.microsoft.com/xps/2005/06/resourcedictionary-key" xml:lang="en-us" Width="793.92" Height="1122.24"><FixedPage.Resources><ResourceDictionary><LinearGradientBrush x:Key="b0" StartPoint="0,0" EndPoint="0,1122.24" ColorInterpolationMode="SRgbLinearInterpolation" MappingMode="Absolute" SpreadMethod="Pad"><LinearGradientBrush.GradientStops><GradientStop Color="#FFFFFFFF" Offset="0" /><GradientStop Color="#33888800" Offset="1" /></LinearGradientBrush.GradientStops></LinearGradientBrush>'''
pat = '="(.*?)"'
match = re.findall(pat,xml)
print match
Here the above code I wrote find values like http://schemas.microsoft.com/xps/2005/06, #FFFFFFFF , #33888800 etc from the XML.It can be integer, float, string whatever. But I wanna modify the main xml string such way that if the value is a integer it will replace the value with <integer>, if the value is a string it will replca it with <string>...and give the modified xml as output.
Thanks in Advance.