Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Search Replace XML or HTML elements

2005-11-21
2012-11-13
  • I am new to Notepad++ and I like the interface a lot. There is one important editing task I cannot figure out how to do, so I assume I am asking for a new feature.

    It seems that regular expressions are limited to one line at the time in the current implementation (3.3). I would like the capability to search for entire XML, HTML (or other SGML derivative) elements. For example, the option to find the parent1 element in the example below.

    <parent-element name="parent1">
        <child-element name="child1"/>
        <child-element name="child2"/>
    </parent-element>
    <parent-element name="parent2">
        <child-element name="child1"/>
        <child-element name="child2"/>
    </parent-element>

    Thanks,
    /NHL

     
    • I know how to search for a string. What I need is a way to find the entire parent1 element.
      Here is an example: Assume I want to change the name of child1 inside parent1 but not inside parent2. I could do that with a regular expression if the expression worked over multiple lines.
      Believe me, this is a scenario I have to deal with quite often. Fortunately there are other tools I can use, but it would be convenient to have it in NPP.

      /NHL

       
    • Paulius
      Paulius
      2005-11-22

      so if you enter "parent1" in the search field - Notepad++ will find (and mark) the text "parent1". What is the problem?
      if you want all the tag to be found - enter "<parent-element name="parent1">" in the search field and it will be found. Or you can use a regex to find it - regex like this: "<[^<>]*parent1[^<>]*>" - it will mark any tag, that has "parent1" inside it (in any attribute etc).
      I hope it helps. If not - please explain what is the problem in more detail.