0

Hi new to Xpath and hoping this makes sense...

Only interested in a specific element and its attribute values... the issue I'm running into is this element contains nested elements.

Please note: TASK is not the Root element...

Here's an example:

     <TASK CHAPNBR="00" FUNC="000" PGBLKNBR="0" SECTNBR="00" SEQ="000" SUBJNBR="00" PGBRK="NO">
        <EFFECT/>
        <TITLE>Aircraft Pre-Dock</TITLE>
        <TOPIC PGBRK="NO">
           <EFFECT/>
           <TITLE>Aircraft Exterior walk around GVI from Ground Level.</TITLE>
           <SUBTASK CHAPNBR="00" FUNC="000" PGBLKNBR="0" SECTNBR="00" SEQ="000" SUBJNBR="00" PGBRK="NO">
              <LIST1>
                 <L1ITEM PGBRK="NO">
                    <PARA>Radome and Fuselage</PARA>
                 </L1ITEM>

Only interested in the TASK element and its attributes... so need the Xpath to return this string no matter what the attribute values

    <TASK CHAPNBR="00" FUNC="000" PGBLKNBR="0" SECTNBR="00" SEQ="000" SUBJNBR="00" PGBRK="NO">

Thank you for any assistance! :)

R.Bowe
  • 1
  • 2
  • Is it always the same set of attributes? Xpath doesn't automatically format the result as XML, but you can use concat() with string literals... – DrWatson Sep 23 '15 at 19:58
  • Hi... yes, always the same set of attributes, thanks. – R.Bowe Sep 24 '15 at 12:36

1 Answers1

0

It would probably be something along the lines of

concat('<TASK CHAPNBR="', //TASK/@CHAPNBR, '" FUNC="', //TASK/@FUNC, '" etc. >')

and so on. This assumes that you only have one TASK element, and the set of attributes you need to retrieve is always the same.

DrWatson
  • 418
  • 3
  • 9
  • Thank you for the information... receiving this error message in BaseX 7.7 - "Attributes cannot be serialized"... – R.Bowe Sep 24 '15 at 12:47
  • See http://stackoverflow.com/questions/24663393/basex-attributes-cannot-be-serialized – DrWatson Sep 24 '15 at 13:35