Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selecting items and handle them sequentially #349

Open
moelfassi opened this issue Jul 13, 2019 · 4 comments
Open

selecting items and handle them sequentially #349

moelfassi opened this issue Jul 13, 2019 · 4 comments

Comments

@moelfassi
Copy link

moelfassi commented Jul 13, 2019

Subject of the issue

this is my page:
var html =
"<div class='time_head'>time_head content1</div>"
+ "<div class='blockfix'>blockfix1</div>"
+ "<div class='blockfix'>blockfix2</div>"
+ "<div class='time_head'>time_head content2</div>"
+ "<div class='blockfix'>blockfix3</div>"
+ "<div class='blockfix'>blockfix4</div>"
+ "<div class='blockfix'>blockfix5</div>";

i need to get the results in that order like :
TIME_HEAD CONTENT1
----blockfix1
----blockfix2
TIME_HEAD CONTENT2
----blockfix3
----blockfix4

this what i tried so far:
x(html, {
head: ['.time_head'],
games: ['.blockfix']

})(function (err, obj) {
console.log(obj['head']);
console.log(obj['games']);
});

Actual behaviour

but the result is:

[ 'time_head content1', 'time_head content2' ]
[ 'blockfix1', 'blockfix2', 'blockfix3', 'blockfix4', 'blockfix5' ]

@lathropd
Copy link
Collaborator

Is the number of time_head divs consistent?

@moelfassi
Copy link
Author

Is the number of time_head divs consistent?

No.. they are dates of events

@lathropd
Copy link
Collaborator

I think the solution is to capture them non-sequentially then sort them is a post-processing step.

@SacDin
Copy link

SacDin commented Mar 27, 2020

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants