Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #1485 > unrolled thread
| Started by | "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> |
|---|---|
| First post | 2011-05-10 16:23 +0200 |
| Last post | 2011-05-10 16:23 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.php
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: DOM and node "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-05-10 16:23 +0200
| From | "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> |
|---|---|
| Date | 2011-05-10 16:23 +0200 |
| Subject | Re: DOM and node |
| Message-ID | <iqbhor$ad5$1@dont-email.me> |
El 10/05/2011 13:48, smerf escribió/wrote:
> I have XML like this :
>
> <li>
> Producer:
> <strong>
> <a href="link.html">Name</a>
> </strong>
> </li>
>
>
> How to get only "Producer:" without value of <strong> node ?
>
> I would like to do it in a preety way using built-in PHP classes of DOM
> family.
>
> I can't find solution better then :
> $nodeLI->nodeValue and REGEX
>
> How do you process XML like this one?
If the structure won't change, you can do this:
<?php
$xml_string = '<?xml version="1.0" encoding="ISO-8859-1"?>
<li>
Producer:
<strong>
<a href="link.html">Name</a>
</strong>
</li>';
$doc = new DOMDocument;
libxml_use_internal_errors(TRUE);
$doc->loadXML($xml_string);
libxml_use_internal_errors(FALSE);
$lists = $doc->getElementsByTagName('li');
foreach($lists as $li){
var_dump($li->firstChild->nodeValue);
}
You can trim() the value if you wish.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Back to top | Article view | comp.lang.php
csiph-web