Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
.Paul
[PHP] How to load xml to assocticative array?
Assuming I have an XML that looks like this:
<xml>
<blupp>
<blah id="xyz">
<foo id="123">Hello</foo>
<foo id="456">World</foo>
</blah>
<blah id="zyx">
<foo id="123">Foo</foo>
<foo id="456">Bar</foo>
<foo id="789">Var</foo>
</blah>
</blupp>
</xml>
What would I have to do to get an associative array that looks like this:
array(
xyz => array(
123 => Hello
456 => World
)
zyx => array(
123 => Foo
456 => Bar
789 => Var
)
So far I have this, but I don't know if it's the best way:
$blahs = $this->DOMNodeList->QueryXPath( '/blupp/blah' );
foreach( $blahs as $blah ) {
$blahId = $blah->getAttribute( 'id' );
$foos = $this->DOMNodeList->QueryXPath( '/blupp/blah[@id="' . $blahId . '"]/foo' );
foreach( $foos as $foo ) {
$fooId = $foo->getAttribute( 'id' );
$fooVal = $foo->nodeValue;
$fooItem[$fooId] = $fooVal;
}
$this->blah[$blahId] = $fooItem;
unset($fooItem);
}
1 AnswerProgramming & Design1 decade agoAre you pro life or pro choice?
First of all, I want you all to watch this video here:
http://www.youtube.com/watch?v=O2l1-kvKomg
Please watch this before answering as it could get a lot of people thinking about it.
Please give reasons why you chose pro life or pro choice.
As for me. I'm pro life, not only am I a young father I also believe giving child life is a gift to this world.
For those who do not understand, here is a quick short term.
If you got your girlfriend pregnant and you would keep the baby no matter what, you are pro life. If you you have to make a decision of keeping the baby or not, you are pro choice.
19 AnswersPregnancy1 decade ago