1

I am using xml and xslt 1.0. Suppose there is my xml structure:

<people>
  <person></person>
  <person></person>
  ...
</peoble>

Then I want to show it like this: N is the node "person" .

I am using bootstrap, and the web content is designed like this:

<div class="row">
  <div>Person1</div>
  <div>Person2</div>
</div>

My problem is, I don't know how to put two elements in the same row. I can't put the first, and later the second, because once the tag row is closed, it can't be open again, and the result is:

Row 1: N1

Row 2: N2

And I want:

Row 1: N1 N2

Row 2: N3 N4

Thanks

Jamie Eltringham
  • 810
  • 3
  • 16
  • 25
sebastia
  • 53
  • 1
  • 4

1 Answers1

0

you can use Jquery .slice() to reduce the set of matched elements: look at my example

var divs = $("div > div");
   for(var i = 0; i < divs.length; i+=2) {
    divs.slice(i, i+2).wrapAll("<div class='row'></div>");
}

var persons = $("people > person");
   for(var i = 0; i < persons.length; i+=2) {
    persons.slice(i, i+2).wrapAll("<div class='row'></div>");
}
.row { 
  border: solid 1px #000; 
  padding: 5px;
  width: 120px;
}

person {
  margin:3px;
  border: 1px solid #000;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
        <div>person1</div>
        <div>person2</div>
        <div>person3</div>
        <div>person4</div>
        <div>person5</div>
        <div>person6</div>
</div>


<people>
  <person>person1</person>
  <person>person2</person>
  <person>person3</person>
  <person>person4</person>
  <person>person5</person>
  <person>person6</person>
</people>
MKAD
  • 447
  • 2
  • 10