XML : cheerio nextUntil for elements not exist?

At the point I can retrieve "G4" and need to loop starting from the element with "G4" to extract out subsequent notes that has <chord/> element until the <notes> element that has no <chord/> element then it will stop.

The closest method I could use but it doesn't fit my requirement or is there a way to loop?

  $(this).next("note").nextUntil(..)    <note default-x="77.35" default-y="-30.00">          <pitch>            <step>G</step>            <octave>4</octave>**            </pitch>          <duration>2</duration>          <voice>1</voice>          <type>quarter</type>          <stem>down</stem>          <staff>1</staff>          </note>        <note default-x="77.35" default-y="-20.00">          <chord/>  //Chord          <pitch>            <step>B</step>            <octave>4</octave>            </pitch>          <duration>2</duration>          <voice>1</voice>          <type>quarter</type>          <stem>down</stem>          <staff>1</staff>          </note>        <note default-x="77.35" default-y="-10.00">          <chord/>  //Chord          <pitch>            <step>D</step>            <octave>5</octave>            </pitch>          <duration>2</duration>          <voice>1</voice>          <type>quarter</type>          <stem>down</stem>          <staff>1</staff>          </note>        <note default-x="140.45" default-y="-20.00">            //// No chord element here.            <pitch>            <step>B</step>            <octave>4</octave>            </pitch>          <duration>2</duration>          <voice>1</voice>          <type>quarter</type>          <stem>down</stem>          <staff>1</staff>          </note>    

No comments:

Post a Comment