About accessing li contents without ul contents inside of that li

im trying to access the text content that is "education" in the given code stand it is written in a li element. But not the text content that are written inside the ul of that li element that is "science" and other li elements inside science. Basically, li has uls and i just want to access li content and not ul's.

<ul class="dropdown-items">
  <li class="li-items">Education
    <ul class="dropdown-items">
      <li data-parent="Education" class="li-items">Science
        <ul class="dropdown-items">
          <li data-parent="Science" class="li-items">Physics</li>
          <li data-parent="Science" class="li-items">Chemistry</li>
          <li data-parent="Science" class="li-items">Biology</li>
        </ul>
      </li>
  </ul>
 </li>
 <li class="li-items">Entertainment</li>
 <li class="li-items">Spiritual</li>
</ul>

               

that was my html that come out dyanamically because of following code in template:

<ul class="dropdown-items">
{% for cat in cats %}
{% if not cat.children.all %}
<li {% if cat.parent %} data-parent="{{cat.parent.name}}" {% endif %} class="li-items">{{cat.name}}
{%else%}
<li {% if cat.parent %} data-parent="{{cat.parent.name}}" {% endif %} class="li-items">{{cat.name}}
    {% include "blog/category.html" with cats=cat.children.all %}
</li>
</li>
{% endif %}
{% endfor %}
</ul>
Back to Top