在xml搜索中选择最后一个结束标记

问题描述

我使用的是 opencart V 3.0.3.7

我在树枝文件中有一个代码结构

<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

我想在 xml 文件搜索最后一个

首先,像

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

如何搜索LAST ???

解决方法

您有四个 <ul> 标签。最后一个标签index是3。因此,您可以在 index="3" 标记中添加 XML search

在哪个位置之后添加这个。

有三个位置:

您可以根据代码要求添加任何位置。

position="(replace|before|after)"

更改行:

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

完整示例:

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Select Last Closing Tag Example</name>
    <version>1.0</version>
    <author>Mujahid Bhoraniya | bhoraniyamujahid@gmail.com</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>