问题
Here i want insert a LI item inside existing UL
I tried this,
XML
<ul id="top_menu">
<li><a>1</a></li>
<li><a>2</a></li>
<li><a>3</a></li>
</ul>
XPATH
<xpath expr="//ul[@id='top_menu']/li[1]" position="after">
<li><a>100</a></li>
</xpath>
I got my new item "100" at last item of <ul>
. but i need it in after 1st item.
Thanks in advance.
回答1:
Sometime in tricky solution, we need to override/replace base id and than rearrange it based on our requirement.
try with this code:
Replace your code
<xpath expr="//ul[@id='top_menu']/li[1]" position="after">
<li><a>100</a></li>
</xpath>
with
<xpath expr="//ul[@id='top_menu']" position="replace">
<ul id="top_menu">
<li><a>1</a></li>
<li><a>100</a></li>
<li><a>2</a></li>
<li><a>3</a></li>
</ul>
</xpath>
来源:https://stackoverflow.com/questions/35124359/qweb-xpath-of-child-node-in-odoo-openerp