2

I need add tag <sheet> inside <form> using xpath. I have tried below code:

<xpath expr="//form[@string='Bank account']" position="inside">
   <sheet></sheet>
</xpath>

The sheet added but after the form tag.

enter image description here

How can i do it?

KbiR
  • 4,047
  • 6
  • 37
  • 103
  • I think string is not valid in xpath please try with form name.expr="//form[@name='name of you form']" –  Mar 21 '17 at 13:28
  • There is no name for that form tag. – KbiR Mar 21 '17 at 13:32
  • Then you need to give name of particular field from form in xpath and give position before or after which ever your need. –  Mar 21 '17 at 13:42

2 Answers2

0

please try

<xpath expr="//form" position="inside">
  <sheet></sheet>
</xpath>

or

<xpath expr="//form/group[1]" position="before">
  <sheet></sheet>
</xpath>

if you gave any group tags inside form

Hilar AK
  • 1,655
  • 13
  • 25
0

When you use position="inside" what happens is that the sheet you are inserting is appended as the last item inside of your form. You do not need that, what you need is for the form //form[@string='Bank account'] to contain a sheet and that sheet to contain all the children of the form.

See if the xpaths below work for you:

<xpath expr="//form[@string='Bank account']" position="inside">
   <sheet>
     <xpath expr="//form[@string='Bank account']/[not(name()='sheet')]"/>
     <xpath expr="//form[@string='Bank account']/[not(name()='sheet')]" position="replace"/>
   </sheet>
</xpath>

What I do here is:

1) Add the sheet inside the form

2) Select all the items in the form(besides the sheet I just added and put them inside the sheet.

3) To avoid having items both in the sheet and outside, I remove the outside.

George Daramouskas
  • 3,720
  • 3
  • 22
  • 51
  • Could you explain this `/[not(name()='sheet')` . The fields not coming inside the sheet. – KbiR Mar 23 '17 at 06:20