Xpath problem, getting the id(attribute) of a element, if you know the title of the element.
Posted
by
user577823
on Stack Overflow
See other posts from Stack Overflow
or by user577823
Published on 2011-01-16T21:50:13Z
Indexed on
2011/01/17
21:53 UTC
Read the original article
Hit count: 263
Hi guys,
My question is, is it possible to get the Article ID, when you have the title of the article?(via xpath)
Articles
Article ID="1"
title crack /title
content blablabalbal /content
/Article
/Articles
Because i am using this right now, it isnt working though.
$xml = simplexml_load_file("Articles.xml");
$XElement = new SimpleXMLElement($xml->asXML());
$Articles = $XElement->xpath("Article");
$title = "crack";
$elements = count($Articles);
for($i = 0; $i title;
if($Titles == $title) //This is not working? i dont know why?
{
$AID = (string)$Articles[$i][@"ID"];
}
}
© Stack Overflow or respective owner