VMJ Creations
VMJ Creations

Reputation: 13

selecting last closing tag in xml search

I am using opencart V 3.0.3.7

I have a code structure in twig file like

<ul> // this is fixed
  <li>
   {% if somecondition %}
     <ul>
        <li>   </li>
     </ul> // Here <ul> </ul> is added dymanically...so number of <ul> </ul> tags is not fixed.
   {% endif %}
  </li>
</ul> // this  is fixed. want to search this tag in xml

I want to search last in xml file

For first instance, works like

 <search index="0"><![CDATA[<ul>]]></search> 

How to search LAST ???

Upvotes: 0

Views: 139

Answers (1)

Mujahid Bhoraniya
Mujahid Bhoraniya

Reputation: 1584

You have four <ul> tags. And the last tag index is 3. So you can add in XML index="3" in the search tag.

And after which position you add this.

There is three-position:

You can add any position as per your code requirements.

position="(replace|before|after)"

Change Lines:

<search index="3" position="after"><![CDATA[<ul>]]></search>

Full Examples :

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Select Last Closing Tag Example</name>
    <version>1.0</version>
    <author>Mujahid Bhoraniya | [email protected]</author>
    <code>Mujahid Bhoraniya Coder</code>
    <link>http://www.opencart.com</link>
    <file path="">
        <operation>
            <search index="3" position="after"><![CDATA[<ul>]]></search>
            <add><![CDATA[]]></add>
        </operation>
    </file>
</modification>

Upvotes: 0

Related Questions