Apr-12-2022, 03:06 PM
Hi, I have 2 types of files - one is base XML file where are some attribute values = "FAIL" and i the other file - text file where are values I want to use instead of those "FAIL".
Picture below explain visualy what I mean:
![[Image: 31R1A.png]](https://i.stack.imgur.com/31R1A.png)
I need somehow to put in in correct place and I have no idea how to do it. I have been thinking about formating this text file to another XML file and then parse them both and replace value but I has to be done easier, and It would be perfect if it is possible without parsing XML file because it destroy structure of it (deletes whitespaces, sort attributes etc.). I tought about using regex to first find in text file Object id (number before "=>"), then attribute name (string between "=>" and ":") and then find value (string between Attribute name + ":" and "<END_OF_OBJECT_LINE>" or "<COMMA>") and somehow put in in XML but also I am not sure how to do it.
XML file:
Picture below explain visualy what I mean:
![[Image: 31R1A.png]](https://i.stack.imgur.com/31R1A.png)
I need somehow to put in in correct place and I have no idea how to do it. I have been thinking about formating this text file to another XML file and then parse them both and replace value but I has to be done easier, and It would be perfect if it is possible without parsing XML file because it destroy structure of it (deletes whitespaces, sort attributes etc.). I tought about using regex to first find in text file Object id (number before "=>"), then attribute name (string between "=>" and ":") and then find value (string between Attribute name + ":" and "<END_OF_OBJECT_LINE>" or "<COMMA>") and somehow put in in XML but also I am not sure how to do it.
XML file:
<Module bs="Mainfile_1">
<object id="1000" name="namex" number="1">
<item name="item0" value="100" />
<item name="item00" value="100" />
</object>
<object id="1001" name="namey" number="2">
<item name="item1" value="100" />
<item name="item00" value="100" />
</object>
<object id="1234" name="name1" number="3">
<item name="item1" value="FAIL" />
<item name="item2" value="233" />
<item name="item3" value="233" />
<item name="item4" value="FAIL" />
</object>
<object id="1238" name="name2" number="4">
<item name="item8" value="FAIL" />
<item name="item9" value="233" />
</object>
<object id="2345" name="name32" number="5">
<item name="item1" value="111" />
<item name="item2" value="FAIL" />
</object>
<object id="2347" name="name4" number="6">
<item name="item1" value="FAIL" />
<item name="item2" value="FAIL" />
<item name="item3" value="233" />
<item name="item4" value="FAIL" />
</object>
</Module>Text file: 1234=>item1:something11:
something11<COMMA>item4:something12:
12something<END_OF_OBJECT_LINE>
1238=>item8:something12:
something11:<END_OF_OBJECT_LINE>
2345=>item2:something12:
something11:<END_OF_OBJECT_LINE>
1234=>item1:something1:
something11<COMMA>item2:something:
11something<COMMA>item4:something:
11something<END_OF_OBJECT_LINE>
