Can xpath select from one element to a different type of element? -


New camera for xpath, so perhaps it does not know the vocabulary to properly search.

I want to take the end of a paragraph with a specific ID from the beginning of a div with a specific ID. Note that I only want to select the part of the div. & lt; body & gt; & Lt; Div id = "meaninglessPreamble" & gt; Do not get this data. & Lt; / Div & gt; & Lt; Div id = "wrapper" & gt; & Lt; Div id = "grab this" & gt; Good things & lt; / Div & gt; & Lt; P id = "grab thisToo" & gt; Better things & lt; / P & gt; & Lt; P id = "endHere" /> & Lt; P id = "leaveMeOutOfThis" & gt; Unwanted junk & lt; / P & gt; & Lt; / Div & gt; & Lt; / Body & gt;

The more general viewpoint, you are the lower-siblings and the ex-siblings You can try to select a range of elements by ID attributes.

  / body / div [@ id = 'wrapper'] / * [(predecessor-sibling :: * [@ id = 'grab this'] or @ id = 'grab' ) And (following-sibling :: * [[id = 'end here'] or @ id = 'end here')]   

All children above the example show a selection of elements & lt; Div id = "wrapper" & gt; Include the element with the id = "endHere" with the element , id = "grab this" . If you want to select it specifically (exclude limited elements), just remove the or @id = '...' section.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -