PHP bir DOMElement belirli bir çocuk etiketi alın

0 Cevap php

I am walking through a xml definition file and I have a DOMNodeList that I am walking through. I need to extract the contents of a child tag that may or may not be in the current entity

<input id="name">
  <label>Full Name:</label>
  <required />
</input>
<input id="phone">
  <required />
</input>
<input id="email" />

I need to replace ????????????? with something that gets me the contents of the label tag if it exists.

Kod:

foreach($dom->getElementsByTagName('required') as $required){
  $curr = $required->parentNode;

  $label[$curr->getAttribute('id')] = ?????????????
}

Beklenen Sonuç:

Array(
  ['name'] => "Full Name:"
  ['phone'] => 
)

0 Cevap