Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XML Question

Reply
Thread Tools

XML Question

 
 
Skeets
Guest
Posts: n/a
 
      02-27-2006
using php5 and given the code at the bottom of this post, this code
works to print the expected value:

foreach ($entry1 as $entry) {
echo "Found {$entry->nodeValue}</br";
}
// prints "Found My List"

however, this code does not work:

echo "Found {$entry->nodeValue}</br";
// prints "Found"

how come?

what can i do to isolate the element text value without the foreach
loop? i've tried absolutely everying that i can think of without any
good results.

tia....

----code----

$doc = new DOMDocument;
$doc->preserveWhiteSpace = false;
$doc->Load('default_conf/book.xml');
$xpath = new DOMXPath($doc);
$query1 = '//book/title';
$entry1 = $xpath->query($query1);

foreach ($entry1 as $entry) {
echo "Found {$entry->nodeValue}</br";
}

 
Reply With Quote
 
 
 
 
Crutcher Dunnavant
Guest
Posts: n/a
 
      02-27-2006
Um, looks like '$entry1' is a list of xpath results.
What does $entry1[0]->nodeValue give you?

 
Reply With Quote
 
 
 
 
Skeets
Guest
Posts: n/a
 
      02-28-2006
i get an error b/c some function can't run. i will try and post the
specific error tomorrow.

 
Reply With Quote
 
Harrie
Guest
Posts: n/a
 
      02-28-2006
Skeets said the following on 2/27/2006 20:51 +0200:

> foreach ($entry1 as $entry) {
> echo "Found {$entry->nodeValue}</br";


I don't have an answer to your question, but don't you miss a greater
than sign at the end of the "br" element? And if this should be XHTML,
shouldn't the slash be after "br", like so: <br />

It's probably better to format your output with CSS than with (X)HTML's
br element, but this is not the right newsgroup to discuss that.

--
Regards
Harrie
 
Reply With Quote
 
Skeets
Guest
Posts: n/a
 
      02-28-2006
actually, i don't get an error, i get a notice.

code snippet:
$entry1 = $xpath->query($query1);
echo "Found {$entry1->nodeValue}";

php notice:
PHP Notice: Undefined property: DOMNodeList::$nodeValue in
C:\web\html\dmt\_debug_tmp.php on line 26

nothing is printed to the screen after "Found".

anuy guidanc eor suggestions would be appreciated. i find the dearth
of information regarding following a path and retrieving and element
value bizarre - i would've thought this was the first thing someone
would learn.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
Print XML parsing to JspWriter (out) Class org.xml.sax.helpers.NewInstance can not access a member of class javax.xml.parsers.SAXParser with modifiers "protected" Per Magnus L?vold Java 0 11-15-2004 02:27 PM
embedding xml in xml as non-xml :) Mark Van Orman XML 5 09-15-2004 05:57 AM
What XML technologies to learn first for "XML Processing" and "XML Mapping"? Bomb Diggy Java 0 07-28-2004 07:26 AM
Help on including one XML document within another XML document using XML Schemas Tony Prichard XML 0 12-12-2003 03:18 PM



Advertisments