Copying the first few xml elements

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gracec
    New Member
    • Dec 2009
    • 2

    Copying the first few xml elements

    I have an xml file with the overall structure:

    <a>
    <b>
    <c1>
    </c1>
    <c2>
    </c2>
    <c3>
    </c3>
    ..
    ..
    ..
    </b>
    </a>

    The xml file has hundreds of c elements and my goal is to write a xslt file that only copies the first 200 c elements in this file, ie up to and including the <c200> element, and delete the rest of the c elements. Does anyone know how?
    Thanks in advance!
  • gracec
    New Member
    • Dec 2009
    • 2

    #2
    When i say elements above I mean nodes. So what I mean is how to write a xslt file that only copies the first 200 c nodes in a xml file and deletes the rest. Help please.

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      I could imagine that you can make a string comparison of the element name whether it contains a number <= 200. are you sure you mean nodes and not elements (attributes and text also counts as node)?

      if you know the name of the 201st element you can make a for-each loop and use the position as test.

      using DOM and a programming language would be easier though …

      Comment

      Working...