Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [XML][PHP] pobranie tylko wniosków z abstraktu xml
neurogen
post 6.05.2018, 20:12:19
Post #1





Grupa: Zarejestrowani
Postów: 58
Pomógł: 0
Dołączył: 25.03.2018

Ostrzeżenie: (0%)
-----


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>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
trueblue
post 6.05.2018, 20:46:24
Post #2





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


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"]


--------------------
Go to the top of the page
+Quote Post
LowiczakPL
post 7.05.2018, 20:40:34
Post #3





Grupa: Zarejestrowani
Postów: 531
Pomógł: 55
Dołączył: 3.01.2016
Skąd: Łowicz

Ostrzeżenie: (0%)
-----


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.  


Ten post edytował LowiczakPL 7.05.2018, 20:41:06


--------------------
Szukam zleceń Symfony, Laravel, Back-End, Front-End, PHP, MySQL ...
Go to the top of the page
+Quote Post
trueblue
post 7.05.2018, 21:05:18
Post #4





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


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ę.


--------------------
Go to the top of the page
+Quote Post
Pyton_000
post 7.05.2018, 22:54:04
Post #5





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


Co do XPath to powinno wystarczyć
Kod
//AbstractText[@Label="Conclusion"]

a potem sobie przeiterować po kolekcji
Go to the top of the page
+Quote Post
trueblue
post 8.05.2018, 06:35:36
Post #6





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


Pod warunkiem, że AbstractText nie przynależy do innej hierarchii elementów.


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 18.07.2025 - 01:34