Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [XML][PHP] pobranie tylko wniosków z abstraktu xml
Forum PHP.pl > Forum > Przedszkole
neurogen
wiem jak pobrać AbstractText ale jak pobrać tylko ten oznaczony Label="Conclusion"?
próbowałem:
$abstract=$text->MedlineCitation->Article->Abstract->AbstractText['Conclusion'];
albo
$abstract=(string) $text->MedlineCitation->Article->Abstract->AbstractText['Conclusion'];

  1. <Abstract>
  2. <AbstractText Label="Purpose" NlmCategory="UNASSIGNED">We report on an accelerated and effective way of assimilating a new leader into a team at a large academic dental school department.</AbstractText>
  3. <AbstractText Label="Methods" NlmCategory="UNASSIGNED">At University of California, San Francisco (UCSF), a new Chair was recruited through a national search to lead its largest department in the School of Dentistry. Two months after arrival, the new Chair embarked on a process of leadership assimilation among her executive team, facilitated by a professional consultant. Within four weeks, team members participated in one-on-one interviews with the professional facilitator consultant and then completed the leadership assimilation questionnaire and returned it electronically to the facilitator. The facilitator then summarized all answers into themes and met with the team members without the Chair to debrief. Thereafter, the facilitator met with the Chair to discuss the major themes. Next, the Chair met with the team members in a facilitated session to discuss the results and negotiate a path forward.</AbstractText>
  4. <AbstractText Label="Results" NlmCategory="UNASSIGNED">Approximately half of the feedback described the &quot;how&quot; of leadership: comments on communication, building relationships, building trust, and understanding UCSF history. The remaining half described the &quot;what&quot;: comments on vision, strategy, and operations. Team members indicated that the first debriefing session was helpful to alleviate initial anxiety and to start building team spirit. The session with the Chair was perceived as open and fruitful in which team members were able to express their concerns and hopes for the Department, while the Chair showed commitment to the team and the communication process.</AbstractText>
  5. <AbstractText Label="Conclusion" NlmCategory="UNASSIGNED">Leader assimilation allows teams to share their expectations and anxieties with the new leader early in the relationship in an open way, before new habits and beliefs are formed. Conversely, for the leader, it effectively and efficiently allows a window into the team members' thinking at a critical time period when otherwise first impressions occur. With a safe space created for open communication, the process allowed siloed individual division leaders to move toward a cohesive group while at the same time solidifying a commitment to the success of the new leader.</AbstractText>
  6. </Abstract>
trueblue
Zapoznaj się z metodą query z klasy DOMXPath.

Nie wiem jak wygląda w pełni struktura XML, ale XPath będzie kończył się:
MedlineCitation/Article/Abstract/AbstractText[@Label="Conclusion"]
LowiczakPL
jeśli AbstractText to obiekt to tak

  1. <?php
  2.  
  3. function xml_attribute($object, $attribute)
  4. {
  5. if(isset($object[$attribute]))
  6. return (string) $object[$attribute];
  7. }
  8.  
  9. echo xml_attribute($AbstractText, 'Label');
  10.  
trueblue
Autor nie poszukuje wartości atrybutu (zresztą tą zna, więc po co miałby "wyłuskiwać"), ale chce odfiltrować elementy z atrybutem o takiej wartości.
Chyba, że funkcja ma być użyta w instrukcji warunkowej. Niemniej najstosowniej użyć, to o czym pisałem - dzięki czemu uzyskamy od razu okrojoną tablicę.
Pyton_000
Co do XPath to powinno wystarczyć
Kod
//AbstractText[@Label="Conclusion"]

a potem sobie przeiterować po kolekcji
trueblue
Pod warunkiem, że AbstractText nie przynależy do innej hierarchii elementów.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.