First, you'll need to have your markup within the curly braces that belong to the foreach loop. Otherwise, the scope of the $post object you're referencing will not be available, and it give you an error This is what I came up with: ul> xpath("/tumblr/posts/post/tag/.."); foreach($posts as $post) { echo " ".($post->{'regular-title'}? $post->{'regular-title'}:$post->{'link-text'})." "; }?
> xpath("/tumblr/posts/post/tagcontains(text(),'xml') or contains(text(),'php') or contains(text(),'firefox')/.."); foreach($posts as $post) { echo " ".($post->{'regular-title'}? $post->{'regular-title'}:$post->{'link-text'})." "; }? > xpath("/tumblr/posts/post/tagcontains(text(),'xml') or contains(text(),'php') or contains(text(),'firefox')/.."); foreach($posts as $post) { if ($post->{'regular-title'}) { $slug = $post->{'regular-title'}; } else if ($post->{'link-text'}) { $slug = $post->{'link-text'}; } else { $slug = $post'url-with-slug'; } echo " ".
$slug." "; }? > However, that should work jfcoder.com/test/tumblrtest.php The XPath selects all TAG elements that belong to a POST element, then selects the parent ( ) of that TAG which gives you a SimpleXML object containing the relevant POST elements you're looking for Then, it iterates over each element, printing the $post s information into a UL element.
First, you'll need to have your markup within the curly braces that belong to the foreach loop. Otherwise, the scope of the $post object you're referencing will not be available, and it give you an error. This is what I came up with: xpath("/tumblr/posts/post/tag/.."); foreach($posts as $post) { echo " ".($post->{'regular-title'}?
$post->{'regular-title'}:$post->{'link-text'}). " "; }? > And if you want to limit the tags matched, you can do the following: xpath("/tumblr/posts/post/tagcontains(text(),'xml') or contains(text(),'php') or contains(text(),'firefox')/.."); foreach($posts as $post) { echo " ".($post->{'regular-title'}?
$post->{'regular-title'}:$post->{'link-text'}). " "; }? > Of course, that's a little messy.
I'm not necessarily an XPath guru, so there should be a cleaner way than that I would think. And since I wasn't really digging on the ternary for the link text, or the fact I don't know if one or the other will always be available, this should be more descriptive with a fallback to the url. Xpath("/tumblr/posts/post/tagcontains(text(),'xml') or contains(text(),'php') or contains(text(),'firefox')/.."); foreach($posts as $post) { if ($post->{'regular-title'}) { $slug = $post->{'regular-title'}; } else if ($post->{'link-text'}) { $slug = $post->{'link-text'}; } else { $slug = $post'url-with-slug'; } echo " ".
$slug. " "; }? > EDIT And, you also might want to make a match of the entire text of the TAG element, so that you don't get matches on things like xml-is-for-noobs when you want xml tags only.Contains() will match both, while the below will only match xml.
/tumblr/posts/post/tagtext() = 'xml'/.. So, according to your comment, if you're looking for posts tagged events but don't want to catch tags like bowling-events, prevents fun, other events, etc..., you would want to make the text() = 'events' match. On the other hand, if you DID want to match anything with events in the text of the TAG node, use the contains(text(), 'events') method. EDIT 2 And if you're trying to limit the results, use position(): (/tumblr/posts/post/tagtext() = 'xml'/..)position() However, that should work.
jfcoder.com/test/tumblrtest.php The XPath selects all TAG elements that belong to a POST element, then selects the parent (..) of that TAG, which gives you a SimpleXML object containing the relevant POST elements you're looking for. Then, it iterates over each element, printing the $post's information into a UL element.
I'm kinda understanding how this works now. But I don't see how you can change what tags should the post come up? Because for my client, I need to get all posts that are tagged 'events'.... for example I used to get all posts that are tagged file... – kdevs3 Jul 23 at 16:35 btw thank you for helping – kdevs3 Jul 23 at 16:35 That's the contains() part.
From what it sounds like, you would have one contains statements that was /tumblr/posts/post/tagcontains(text(),'events')/... – Jared Farrish Jul 23 at 16:36 Oops, in the above comment I forgot the trailing /.. to select the parent (which I fixed). – Jared Farrish Jul 23 at 16:38 See my last edit about full text matching versus subtext matching. – Jared Farrish Jul 23 at 16:51.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.