gromer Posted September 21, 2007 Share Posted September 21, 2007 I'm writing a web page for a company that sends xml to a server. That server then responds to me with xml. I can take that xml in and output it using fgets, but all the xml tags are striped. That is useless to me. Is there a way to preserve the tags? Code: $xmlRequest = fsockopen($hostname, $port); fputs($xmlRequest, $xmlToSend); while (!feof($xmlRequest)) { $xml .= fgets($xmlRequest, 1024); } fclose($xmlRequest); echo $xml; $xmlToSend is the xml that I send. Help would be very appreciated Quote Link to comment https://forums.phpfreaks.com/topic/70189-solved-help-reading-in-xml-from-a-stream/ Share on other sites More sharing options...
gromer Posted September 21, 2007 Author Share Posted September 21, 2007 Also, I've been searching Google forever and have searched these forums. I am running php 4.1.x. Quote Link to comment https://forums.phpfreaks.com/topic/70189-solved-help-reading-in-xml-from-a-stream/#findComment-352545 Share on other sites More sharing options...
gromer Posted September 21, 2007 Author Share Posted September 21, 2007 Anyone? Still haven't figured this out and none of my php books are helping. Quote Link to comment https://forums.phpfreaks.com/topic/70189-solved-help-reading-in-xml-from-a-stream/#findComment-352652 Share on other sites More sharing options...
gromer Posted September 22, 2007 Author Share Posted September 22, 2007 Can this be done? Quote Link to comment https://forums.phpfreaks.com/topic/70189-solved-help-reading-in-xml-from-a-stream/#findComment-352913 Share on other sites More sharing options...
Crew-Portal Posted September 22, 2007 Share Posted September 22, 2007 You make an account and use 4 posts on a topic and that brings your total posts to 4. Please wait some people need to see your code first! just shhhhh... Calm down and allow people to read your post. I dont quite get what you mean? Can you rephraise it?! You may also want to post your comment in an XML forum Quote Link to comment https://forums.phpfreaks.com/topic/70189-solved-help-reading-in-xml-from-a-stream/#findComment-353052 Share on other sites More sharing options...
gromer Posted September 22, 2007 Author Share Posted September 22, 2007 You make an account and use 4 posts on a topic and that brings your total posts to 4. Please wait some people need to see your code first! just shhhhh... Calm down and allow people to read your post. I dont quite get what you mean? Can you rephraise it?! You may also want to post your comment in an XML forum I really could care less about my post count, reset it to 0 for all I care. What else do you need in my post anyways? I need to input XML sent to me from another server, preserving the XML tags. My code is all of 10 lines, and when the thread goes off the main page, who is going to look at it? Yes, this topic involves XML, but it is a php question, that's why I made this thread here since it is php specific. If I was using ASP, this would have been done with no problems. Okay, I'm not being an ass, I'm just really rushed in getting a solution for this. It bugs me that this would be so much easier in ASP over php, but there is no way I'm going to convince this company to redo their whole server setup to run 2003 over Linux and Mono is not an option. I will try to clarify some things here...they use this wierd XMLCommander software on clients servers. What I do from this website is send XML to their server, where XMLCommander interprets it and responds to me with XML. I need to parse that XML and use it to customize the website for the customer, since all their data is stored on their server. I'm using fsockopen to open the connection to their server and then using fputs to put the XML I am sending on their server. I then used fgets to read the response in, but all the XML tags are stripped. Instead of: <Root> <Customer> <CustomerName>Jim Jones</CustomerName> <CustomerEmail>jim.jones@somecompany.com</CustomerEmail> </Customer> </Root> I get: Jim Jones jim.jones@somecompany.com This is a big problem because if the XML syntax is ever changed and I write code to assume the first element is the name I could have major problems in the future. The first element could be changed to the email address and I'd be reading it in as the customer's name. Sorry to post so much, this is just a VERY large problem and is causing me to sit on my butt doing nothing Quote Link to comment https://forums.phpfreaks.com/topic/70189-solved-help-reading-in-xml-from-a-stream/#findComment-353055 Share on other sites More sharing options...
gromer Posted September 24, 2007 Author Share Posted September 24, 2007 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/70189-solved-help-reading-in-xml-from-a-stream/#findComment-354457 Share on other sites More sharing options...
Barand Posted September 25, 2007 Share Posted September 25, 2007 instead of echo $xml; what does this give? echo '<pre>', htmlentities($xml), '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/70189-solved-help-reading-in-xml-from-a-stream/#findComment-354479 Share on other sites More sharing options...
gromer Posted September 25, 2007 Author Share Posted September 25, 2007 instead of echo $xml; what does this give? echo '<pre>', htmlentities($xml), '</pre>'; Very awesome, that does what I need. Thank you much!! Quote Link to comment https://forums.phpfreaks.com/topic/70189-solved-help-reading-in-xml-from-a-stream/#findComment-355184 Share on other sites More sharing options...
Barand Posted September 25, 2007 Share Posted September 25, 2007 You still need to parse the xml to get the data, but that code will show you that the tags are still there in $xml, it's just that they don't echo. Just as echo "<p>Hello world</p>" doesn't show the "p" tags Quote Link to comment https://forums.phpfreaks.com/topic/70189-solved-help-reading-in-xml-from-a-stream/#findComment-355189 Share on other sites More sharing options...
gromer Posted September 25, 2007 Author Share Posted September 25, 2007 You still need to parse the xml to get the data, but that code will show you that the tags are still there in $xml, it's just that they don't echo. Just as echo "<p>Hello world</p>" doesn't show the "p" tags That makes sense. Again, thank you! Quote Link to comment https://forums.phpfreaks.com/topic/70189-solved-help-reading-in-xml-from-a-stream/#findComment-355193 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.