First, I am not a programmer.
I have a huge XML file with terms described thus:
<term>
<termId>MANUAL000399</termId>
<termUpdate>Add</termUpdate>
<termName>care</termName>
<termType>Pt</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20120618T14:38:20</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20120618T14:40:41</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
</term>
In the file, terms have either
<termType>
Pt or ND
I would like the solution to apply to both. what I would like to do is be able to go through, look at the word length in termName and if there are fewer than 5 characters in there, append another property, a
<termNote>
in after the
<termModifiedBy>
property:
<term>
<termId>MANUAL000399</termId>
<termUpdate>Add</termUpdate>
<termName>care</termName>
<termType>Pt</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20120618T14:38:20</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20120618T14:40:41</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termNote label="Short">Short</termNote>
</term>
Can anyone advise what the best approach for this? I found regexes on here but the problem is the application of them, I found someone suggesting /\b[a-zA-Z]{5,}\b/ but I don't know how to write a script that takes this and then inserts the termNote if it matches.