I have got a very big xml document and i have to modify the value of 2 tags there.
</Hours>
<IsBusyHourSet>true</IsBusyHourSet>
<BusyHour>-1</BusyHour>
<DayOfWeek>
<Day>0</Day>
</DayOfWeek>
</DayDetails>
</DayDetailsList>
<DayHourType>Specified</DayHourType>
<IsUsingAllDaysAndHours>true</IsUsingAllDaysAndHours>
</DayHourSettings>
</Value>
</AnalysisParameter>
<AnalysisParameter Id="f7c95" IsPrivate="false" IsReadOnly="false" IsDeletable="true" PromptOnTemplate="false" IsPartitionable="false">
<Name>Time</Name>
<Description>hourly</Description>
<CsvInputReferenceName />
<Value Type="Resources.Utilities.DefaultTimePeriod, Wpf.Resources">
<DefaultTimePeriod>
<Type>SpecificDates</Type>
<SpecificDateStart>2022-09-15T00:00:00</SpecificDateStart>
<SpecificDateEnd>2022-09-15T23:59:59.999</SpecificDateEnd>
<RelativeTimeValue>1</RelativeTimeValue>
<RelativeTimeType>Days</RelativeTimeType>
<RelativeType>TheLast</RelativeType>
</DefaultTimePeriod>
</Value>
</AnalysisParameter>
</AnalysisParameters>
</ParameterStoreForSerialization>
I have to change the value of "SpecificDateStart" and "SpecificDateEnd" (tagname is not unique) which is existing multiple times in documents but i have to change at a specific place only which i have attached
I am using this code
from xml.etree import ElementTree as ET
tree = ET.parse(Document.xml)
tree.find('.//SpecificDateStart').text = '1/1/2011'
This is working but it is changing the first instance of "SpecificDateStart" as the tag name is not unique I have to change it at the 3rd or 4th instance for which iam using another code.
tree.find('/DefaultTimePeriod/SpecificDateStart').text = '1/1/2011'
which is showing me error
'NoneType' object has no attribute 'text'