A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearMy xpath/php output needs to show the tags - page 1
User InfoPosts
My xpath/php output needs to show the tags#1
I(m trying to get an xpath xpression that will remove my outer tag, but it(s removing that, plus the inner tag and printing the element data. How do I get it to print my prompt tags also?

My php looks like this:

<?php
#get file
$xml = simplexml_load_file((content.xml() or die ("Unable to load XML string!");

#loop through results
foreach ( $xml->xpath((//prompt() as $voiceQ) {
echo "<h2>Thank you for visiting our site2</h2>";
print $voiceQ;
} //for
?>


My content.xml looks like this
(I(m writing to this file and it(s losing some formatting. I don(t think this is the problem):

<?xml version="1.0" encoding="UTF-8"?>
<result>
<prompt>
Welcome to Group Finder, Mary Lamb . We see that
you like the group: JackJohnson
</prompt>
</result>


My output looks like this:
Welcome to Group Finder, Mary Lamb . We see that you like the group: JackJohnson

But I want it to look like this:
(just remove result tags):

<prompt>Welcome to Group Finder, Mary Lamb . We see that you  like the group: JackJohnson</prompt>

posted date: 2009-04-12 16:09:00


Re: My xpath/php output needs to show the tags#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-12 16:09:01


Re: My xpath/php output needs to show the tags#3
I figured out that I can write output to screen with prompt tags with print $voiceQ->asXML(); But when I try to write it to my file, it loses the prompt tags again. How do I keep my prompt tags when I write to file?

posted date: 2009-04-12 16:52:00


Re: My xpath/php output needs to show the tags#4
Try the asXML method on SimpleXMLElement:<?php$string = (<?xml version="1.0" encoding="UTF-8"?><result><prompt>Welcome to Group Finder, Mary Lamb . We see that you like the group: JackJohnson</prompt></result>(;#get file$xml = new SimpleXMLElement($string);#loop through resultsforeach ( $xml->xpath((//prompt() as $voiceQ) { echo "<h2>Thank you for visiting our site2</h2>"; print $voiceQ->asXML();} //for?>

posted date: 2009-04-13 03:58:00


Re: My xpath/php output needs to show the tags#5
if result is within prompt just loop a little bit more :) <php? #get file $xml = simplexml_load_file((content.xml() or die ("Unable to load XML string!"); #loop through results foreach ( $xml->xpath((//prompt() as $voiceQ) { foreach($voiceQ AS $inVoice) { echo "<h2>Thank you for visiting our site2</h2>"; print $inVoice; } } //for ?>

posted date: 2009-04-13 18:00:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.