Jump to content

[SOLVED] Help reading in XML from a stream


gromer

Recommended Posts

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 :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :(

       

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.