Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DomCrawler] Added return of element name inextract() method#29127

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@andrey-helldar
Copy link

@andrey-helldarandrey-helldar commentedNov 7, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
LicenseMIT
Doc PRsymfony/symfony-docs#10646

Situation: you need to get an array of keys and values.
The current package code does not allow this to be done easily.
The changes made to the code will allow you to return the required data set.

useSymfony\Component\DomCrawler\Crawler;$crawler =newCrawler($content);$crawler    ->filter('ItemsList > Item')    ->each(function (Crawler$element) {$data =$element            ->children()            ->extract(['_name','_text']);var_dump($data);    });// Result:array:2 [0 => array:2 [0 =>"id",1 =>"1"  ],1 => array:2 [0 =>"title",1 =>"Foo Bar"  ]]

andrey-helldar pushed a commit to andrey-helldar/symfony-docs that referenced this pull requestNov 7, 2018
@andrey-helldarandrey-helldar changed the titleAdded return of element name inextract() method[DomCrawler] Added return of element name inextract() methodNov 7, 2018
@jakzal
Copy link
Contributor

_key isn't accurate. It's a node name, so maybe_name would be more suitable?

@andrey-helldar
Copy link
Author

The hardest thing in development is to come up with a variable name. :)

I considered different names:_name,_key,_tag... and settled on two:_key and_name,

I think you're right._name more appropriate name.

@nicolas-grekas
Copy link
Member

Thank you@andrey-helldar.

andrey-helldar reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas merged commit79162c1 intosymfony:masterDec 1, 2018
nicolas-grekas added a commit that referenced this pull requestDec 1, 2018
…)` method (andrey-helldar)This PR was squashed before being merged into the 4.3-dev branch (closes#29127).Discussion----------[DomCrawler] Added return of element name in `extract()` method| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| License       | MIT| Doc PR        |symfony/symfony-docs#10646Situation: you need to get an array of keys and values.The current package code does not allow this to be done easily.The changes made to the code will allow you to return the required data set.```phpuse Symfony\Component\DomCrawler\Crawler;$crawler = new Crawler($content);$crawler    ->filter('ItemsList > Item')    ->each(function (Crawler $element) {        $data = $element            ->children()            ->extract(['_name', '_text']);        var_dump($data);    });// Result:array:2 [  0 => array:2 [    0 => "id",    1 => "1"  ],  1 => array:2 [    0 => "title",    1 => "Foo Bar"  ]]```Commits-------79162c1 [DomCrawler] Added return of element name in `extract()` method
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestDec 3, 2018
… method (andrey-helldar)This PR was squashed before being merged into the master branch (closes#10646).Discussion----------[DomCrawler] Added return of element name in `extract()` methodSee a PR:symfony/symfony#29127<!--If your pull request fixes a BUG, use the oldest maintained branch that containsthe bug (seehttps://symfony.com/roadmap for the list of maintained branches).If your pull request documents a NEW FEATURE, use the same Symfony branch wherethe feature was introduced (and `master` for features of unreleased versions).-->Commits-------b89cd59 [DomCrawler] Added return of element name in `extract()` method
@amouhzi
Copy link
Contributor

Hello,

And if an attribute with the name_text exists? What's going to happen ?

@nicolas-grekasnicolas-grekas modified the milestones:next,4.3Apr 30, 2019
@fabpotfabpot mentioned this pull requestMay 9, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+1 more reviewer

@ro0NLro0NLro0NL approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

7 participants

@andrey-helldar@jakzal@nicolas-grekas@amouhzi@fabpot@ro0NL@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp