This sample model shows how one can use XPath, an XML Path Language to select a specific node on a page. This is best used to select a specific generated node which may have the same name as several other generated nodes.
XPath Page Location Sample
This sample provides a simple example of how to use XPath in the advanced page location section of a builder. Fist off you will want to make sure Fully Parse Page is checked in the advanced section of the page builder you are referencing. After that you can reference html tags using XPath. This is particularly useful when using a Data Page builder or some other builder that will generate multiple tags with the same class name. In this case the datapage is generating multiple rows with the name
"DisplayField". You will use XPath to slowly drill down the html until you find the appropriate tag. You will want to start at the top of your html page with the first tag (HTML) and work your way down. Any tags that open and close before you get to the tag you wish to reference can be ignored. Only tags that remain open once you reach the tag you wish to reference must be listed in the XPath. Pay close attention to any generated tags which will need to be reference but may not show up on the actual html page. You can see these tags by clicking on the WebApp Tree tab and selecting your page builder. This will show you the html including all generated tags. In this case, there are multiple instances of the tag HTMLWRAPPER which must be referenced for the XPath to work. In my example I decided to add an attribute builder to make the first cell in the third row span multiple columns. To reference this third column I drill down to the appropriate level
I then add a  to reference the third row, which is index 2, starting at 0.
I then add /TD to reference the specific cell.
Now that my XPath statement is complete, I open up the builder I want to go on this tag, and select advanced in the location technique section under page location. I then type in Page XPath . After running the model we can see via webpage appearance or the html source that the attribute colspan="4" has been added to the correct tag.
Notes on running the sample and prerequisites
Import the attached zip file into your project using the Import WebSphere Portlet Factory Archive command and then open the PageLocation model.