我有这个xml文件https://pastebin.com/2PFthem2
我想获取所有讲座的“教室”属性以将其打印为HTML数组
example Classroom =“ B3”我想要B3
到目前为止的代码
x=atomic_pre_increment(&a)-1; y=atomic_pre_increment(&a);
}
答案 0 :(得分:0)
您需要使用getAttribute()
方法,
$lectures = $event->getElementsByTagName( "Lecture" );
$classRoomArray = [];
foreach($lectures as $lecture) {
// getting Classroom attribute of each leature element
$classRoom = $lecture->getAttribute('Classroom');
//push to classroom array
array_push($classRoomArray, $classRoom);
}
echo $classRoomArray; // will print all classroom attribute of all lecture element