Insert xml row



  • I read another post on here and tried following the instructions to use Regex to do this. But when I do the Find, nothing is found.

    My current record looks like:
    ab482928-a992-45f8-bb66-c9c121d23b3a-image.png

    I need to insert a row between PlanDetail and CustomProperties.
    <RemitProvider RemitProviderName=“Payment Center” RemitProviderTIN=“777336666” RemitProviderID=“777336666” />

    I wasn’t sure if my Find/Replace settings might need a tweak - but I tried suggestions from another thread here and had no luck:
    3c137eb5-1a15-4d1c-8e00-b802146eb0ba-image.png

    Any help will be greatly appreciated. I’m trying to help someone else on my work team.

    Thanks!



  • @TJ-Druid

    I’d try a Find what of (?-is)(<PlanDetail.+\R)(?=\x20{4}<CustomProperties) and a Replace with of \1<RemitProvider blahblahblah />\r\n

    Replace by blahblahblah with your blahblahblah. :-)

    You’ll want to change your Search Mode to Regular expression for this.



  • Hello, @tj-druid, @alan-kilborn and All

    Oh ! Seemingly, Alan beat me to it ;-))

    First, just one question :

    Is the line <PlanDetail xsi:nil="true"> always identical ? ( as I suppose that you have several lines, beginning with <PlanDetail, in your current HTML file )

    If the answer is yes :

    • SEARCH <PlanDetail xsi:nil="true">\r\n

    • REPLACE <PlanDetail xsi:nil="true">\r\n\x20\x20\x20\x20<RemitProvider RemitProviderName="Payment Center" RemitProviderTIN="777336666" RemitProviderID="777336666" />\r\n

    • Tick the Wrap around option

    • Select the Extended search mode

    • Click once on the Replace All button or several times on the Replace button


    If the line, beginning with <PlanDetail, may be different : for instance <PlanDetail xsi:nil="false"> or <PlanDetail abc:nil="true"> ), I advice you to prefer the regex mode :

    • SEARCH (?-is)<PlanDetail\x20.+\R(?=\h*<CustomProperties)

    • REPLACE $0\x20\x20\x20\x20<RemitProvider RemitProviderName="Payment Center" RemitProviderTIN="777336666" RemitProviderID="777336666" />\r\n

    • Tick the Wrap around option

    • Select the Regular expression search mode

    • Click once on the Replace All button or several times on the Replace button

    Best Regards,

    guy038

    P.S. :

    Here are two links to get further documentation :

    https://npp-user-manual.org/docs/searching/

    https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation



  • @Alan-Kilborn Thank you! I ended up using guy038’s suggestion. But, I did start with yours.



  • @guy038 Thank you so much. I ended up using your second suggestion. I ran into an issue because my validator did not like the new row between PlanDetail and CustomProperties, but I was able to take what you provided and put the row after CustomProperties instead. I was helping a coworker with a temporary work around and she thanks you too! Happy Holidays, I’m sure Santa will give you something good in your stocking - or at least some good Karma!


Log in to reply