simple XSLT question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madshov
    New Member
    • Feb 2008
    • 20

    simple XSLT question

    Hi,

    I'm pretty new to XSLT, so my question might be really simple:
    How do I get the value og 'subelement Sequence="1"', where 'element Id="NAD01"' is equal to 'MO' in the following XML?

    Code:
    ...
    <segment Id="NAD">
              <element Id="NAD01">BY</element>
              <element Id="NAD02" Composite="yes">
                  <subelement Sequence="1">0987654321</subelement>
                  <subelement Sequence="3">9</subelement>
              </element>
    </segment>
    <segment Id="NAD">
              <element Id="NAD01">MO</element>
              <element Id="NAD02" Composite="yes">
                   <subelement Sequence="1">1234567890</subelement>
                   <subelement Sequence="3">9</subelement>
              </element>
    </segment>
    ...
    Thanks,
    Mads
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you need to dive into XPath (if you have not done yet, you should have a look at the XPath section at W3C)

    the XPath you need should probably look like that....
    Code:
    subelement[@Sequence = 1][ancestor::segment/element[@id = "NAD01"]/text() = "MO"]

    Comment

    • madshov
      New Member
      • Feb 2008
      • 20

      #3
      Thanks! I figured it out!

      Comment

      Working...