search for certain data in a certain tag then copy these records - xml



  • @Terry-R said in search for certain data in a certain tag then copy these records - xml:

    (?-s)^.+?<name>([^<]+?|)’

    Thanks a lot, this one has found al the names.

    I tried the steps to copy the records, but only the tag name is been copied.

    Is there a methode to copy all the recoreds that has the apos in the name ?

    Goal is to paste them in a seperate file.



  • @Momo-Hara said in search for certain data in a certain tag then copy these records - xml:

    I tried the steps to copy the records, but only the tag name is been copied.

    If you ticked the option “bookmark line” when using the find, then each line containing the ' will be selected. Using the copy or cut bookmarked lines WILL copy each line entirely.

    Terry



  • @Terry-R

    Dear

    the line only shows the name tag
    the next line the street,
    etc.

    Would be great if I could copy complete record as only the name tag is selected, it only copies the name tag line



  • @Momo-Hara said in search for certain data in a certain tag then copy these records - xml:

    the line only shows the name tag
    the next line the street,

    You said you ONLY wanted the lines with the <name> tag. Now it seems that that is the start of a multi line record. Even your examples did NOT show any “multi line” records. This is very important otherwise you are just wasting my time.

    You need to better explain and provide better examples of “complete” records so I can help.

    Terry



  • @Terry-R
    Sorry.

    an example

    <Customer>
          <Prime></Prime>
          <Name>D'famillyname name  apos can be everywhere (start middle end) of more then one</Name>
          <Country>Countrycode</Country>
          <Street>streetname</Street>
          <HouseNumber>29</HouseNumber>
          <ZipCode>9790</ZipCode>
          <Language>1</Language>
          <CurrencyCode>EUR</CurrencyCode>
          <VATCode>0 or other value</VATCode>
          <VATStatus>0 or other value </VATStatus>
          <VATNumber> empty or other value</VATNumber>
          <AccountSale>number</AccountSale>
          <CountryVATNumber>Countrycode</CountryVATNumber>
          <Ventil>4 of other value</Ventil>
          <Status>0</Status>
       </Customer>
    

    When I pointed to ‘these record’ in my first question posted, I meant to copy the complete record that has in the name tag an apos.

    My apologies once again.



  • @Momo-Hara said in search for certain data in a certain tag then copy these records - xml:

    an example

    That’s much better. There was no way I could have known that as you never showed this before. In fact everything you asked for pointed to single line records. Now I have the full picture I can design a better regex. So I now have:
    Find What:(?-s)(^.+\R){2}^.+?<name>([^<]+?|)'.+\R(?s).+?</customer>

    There is a proviso with this regex. The <Name> line MUST appear exactly 2 lines below the <customer> line. If this is not the case it becomes more complex. The remaining portion of the regex will mark all lines after the <name> line up to and including the closing </customer> line.

    Try this and advise if it suits, or if needs further tuning.

    Terry



  • @Terry-R

    Dear Terry

    correct, each name tag is second.

    and this expression did the trick. thank a lot.

    Would be great if I understand this expression , so next time if I look for another characer , …

    You already explained: I assume the ^ is the apostrof ’ , so if I want to search something else I need a list of expression symbol that matches the character I’m looking for? Where can I find basis explanation about these expressions?

    To give you some understanding of the regex we have:
    (?-s) work on each line by itself
    ^.+?<name> find lines starting possibly with some characters then must followed by the <name> tag
    [^’<]+? keep on finding characters so long as they are not the ’ nor the <
    ‘[^’] find a ’ character, then immediately following is NOT allowed to be a ’ character.

    Thanks a lot again, you really helped me out .



  • I suggest you head over to https://regex101.com/r/G1m32O/1 where I’ve loaded my regex. As this testing website uses a slightly different engine I had to add 1 character. But the benefit of this site is that it explains each portion of the regex in good detail.

    I don’t actually expect you to immediately understand all of it, but hopefully it has given you inspiration to go ahead and learn more about regular expressions. Read some of the posts in our FAQ section, there are a lot of links that can help you learn.

    Terry



  • @Momo-Hara said in search for certain data in a certain tag then copy these records - xml:

    I assume the ^ is the apostrof ’

    No, this character means 1 of several things depending on where it is used. At the start behind the (?-s)^ it means the start of a line. When used inside the [^<] it means the negation of the following character(s), thus anything but a < character in this case.

    I do strongly suggest learning regex coding, but remember to start small. It can be daunting to attempt to get in this deep straight away. You need to learn as you would build a house. Starting with a good foundation.

    Terry



  • Ok, many thanks for all the information. once I start learning the expression, I will do it step by step… .


Log in to reply