Finding a Same-Level Predecessor in XML using XPath

I have an XML Document I am attempting to get some data from. I have a known quantity, and on the same level and unknown quantity. So the format looks like this:

<header>Unknown Item</header>
<title>Known Item</title>

This is the very simplified version. Now I may have any number of this format in succession, but what I want to be able to do is given the known item, which gives me the ability to navigate to that node, use a built-in way to get the nearest same-level predecessor. Each pair of known and unknown items are tied together in the domain space, but not in the XML.

If it's relevant, this is being done in Scala using Saxon as my parser, working over cleaned HTML. It seems to be that this is a fairly abstract problem, however.


It sounds as if you want to access the preceding-sibling::header[1] e.g.

<xsl:template match="title">
  <xsl:variable name="header" select="preceding-sibling::header[1]"/>

Need Your Help

Commit tran on @@ROWCOUNT

sql transactions

I am trying to wrap a few actions in a transaction so I can determine if I should delete a table in the last step. Here's what I have so far:

Hover not working in JQuery

html jquery

I created a simple DIV, which is located on the edge of the page, and I wrote this, a simple script that moves it.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.