Xpath 1.0 function for Exists

I have the following XML:

        <A>
          <B>
            <Amount>5000</Amount>
            <Start>60</Start>
            <End>65</End>
          </B>
          <B>
            <Amount>3000</Amount>
            <Start>63</Start>
          </B>
	  <B>
            <Amount>1234</Amount>
            <Start>61</Start>
            <End>67</End>
          </B>
        </A>

Open in new window


I want to create two Xpath queries that return me the 'start' and 'end' elements for each B.
Problem is, I now end up with two arrays of different lengths: (60;63;61) and (65;67).
I want to be able to detect which B doesn't have an end-element.

Therefore I should use a function like 'exists' or something like that, but I can only use the Xpath 1.0 library.
Anybody that can help me with this?
adiemeerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Geert BormansConnect With a Mentor Information ArchitectCommented:
you can't do that purely in XPath1.
XPath1 is for addressing a node(set)
The construction of the array happens outside XPath1.
That is where you need to add a dummy

I suggest that you make an array of B nodes and pull out either End or default from it in constructing a second array, whichever programming language you are using

boils down to ... " what programming language are you using?"

you could have a pass using XSLT that introduces a End element having value 999
0
 
Geert BormansInformation ArchitectCommented:
//B[not(End)]
0
 
adiemeerAuthor Commented:
Thanks, this is helping me.
But how do I now construct the array of length 3? (With a dummy for the second element, f.i 65;999;67)
0
All Courses

From novice to tech pro — start learning today.