473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how do i post an xml string in php

hi friends,

i want to pass an xml string as a hidden field on the php page. How do i do it.

I tried to put the input type as hidden and value as the <xml tag\>. on the target page it does not take any data.

Regards,
Anubhav
Aug 2 '08 #1
7 2112
pbmods
5,821 Expert 4TB
Heya, Anubhav.

You might want to store it as a session variable instead.

If you can't use sessions, make sure you're running your XML through htmlentities() before you output it.
Aug 2 '08 #2
Heya, Anubhav.

You might want to store it as a session variable instead.

If you can't use sessions, make sure you're running your XML through htmlentities() before you output it.
Hi i tried to do this but when i take the post data on the target page i only get the xml data i do not get the xml tags. an example would help on this.

Regs,

Anubhv
Aug 4 '08 #3
pbmods
5,821 Expert 4TB
On the form page:
Expand|Select|Wrap|Line Numbers
  1. session_start();
  2. $_SESSION['xml'] = '<xml data />';
  3.  
On the processing page:
Expand|Select|Wrap|Line Numbers
  1. session_start();
  2. $xml = $_SESSION['xml'];
  3.  
Alternatively, you might want to do this, instead:
Expand|Select|Wrap|Line Numbers
  1. $xml = htmlentities('<xml data />', ENT_COMPAT);
  2.  
  3. ?>
  4. <input ... value="<?php echo $xml; ?>" />
  5.  
Aug 4 '08 #4
Hi thanks for the help i tried doing this

but it was removing the xml tags when the response was send to the processing page.

<name> rabert </name> was shown as only rabert
then i used escape characters
&lt;name&gt; rabert &lt;/name&gt; and it worked
but it does not take the following

&lt;member count=22&gt; permanent &lt;/member&gt;

Any Ideas,,
Aug 5 '08 #5
pbmods
5,821 Expert 4TB
Show me the code you're using. It sounds like the XML is not getting properly escaped.
Aug 5 '08 #6
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="ticketxml" id="ticketxml" value= "
  2.             &lt?xml version=\'1.0\' encoding=\'UTF-8\'?&gt;
  3.             &lt;ticket&gt;
  4.              &lt;user&gt;
  5.                 &lt;title&gt;Mr.&lt;/title&gt;
  6.                 &lt;firstname&gt;Chris.&lt;/firstname&gt;
  7.                 &lt;lastname&gt;Elliott&lt;/lastname&gt;
  8.                 &lt;email&gt;chris_elliott@symantec.com&lt;/email&gt;
  9.             &lt;phone&gt;1111111111&lt;/phone&gt;
  10.             &lt;username&gt;~Mr. Chris Elliott &lt;/username&gt;
  11.         &lt;shortdesc&gt;foo&lt;/shortdesc&gt;
  12.         &lt;problemtype&gt;order_billing&lt;/problemtype&gt;
  13.         &lt;zip&gt;&lt;/zip&gt;
  14.         &lt;/user&gt;
  15.             &lt;systeminfo&gt;
  16.             &lt;name&gt;Windows XP 5.1&lt;/name&gt;
  17.         &lt;operatingsystem&gt;
  18.             &lt;name&gt;Windows XP 5.1&lt;/name&gt;
  19.             &lt;localtime&gt;7/8/2008 3:12:49 PM GMT: 0&lt;/localtime&gt;
  20.             &lt;symanteccorelc&gt;Startup Type:  State:  Status:&lt;/symanteccorelc&gt;
  21.         &lt;/operatingsystem&gt;
  22.         &lt;browser&gt;
  23.             &lt;name&gt;Internet Explorer&lt;/name&gt;
  24.             &lt;version&gt;6.0.2900.2180&lt;/version&gt;
  25.         &lt;/browser&gt;
  26.         &lt;memory&gt;
  27.             &lt;total&gt;Total: 3070MB Load: 54 percent&lt;/total&gt;
  28.             &lt;available&gt;46 percent&lt;/available&gt;
  29.         &lt;/memory&gt;
  30.         &lt;diskspace&gt;
  31.             &lt;total&gt;93.1 GB&lt;/total&gt;
  32.             &lt;available&gt;3.32 GB&lt;/available&gt;
  33.         &lt;/diskspace&gt;
  34.         &lt;conntype&gt;lan&lt;/conntype&gt;
  35.         &lt;cpu&gt;2394 Mhz&lt;/cpu&gt;
  36.         &lt;opticaldrives&gt;CD-ROM Drive [D:]  Standard CD-ROM drives&lt;/opticaldrives&gt;
  37.     &lt;/systeminfo&gt; 
  38.     &lt;products&gt;
  39.         &lt;product&gt;
  40.  
  41.             &lt;curdefs&gt;20080708.003&lt;/curdefs&gt;
  42.             &lt;name&gt; Norton AntiVirus&lt;/name&gt;
  43.             &lt;version&gt; 2008&lt;/version&gt;
  44.             &lt;language&gt; English &lt;/language&gt;
  45.             &lt;licensetype&gt; Standard &lt;/licensetype&gt;
  46.             &lt;symskucurrent&gt;&lt;/symskucurrent&gt;
  47.             &lt;symskufamily&gt;&lt;/symskufamily&gt;
  48.             &lt;symskumedia&gt;&lt;/symskumedia&gt;
  49.             &lt;partnername&gt;&lt;/partnername&gt;
  50.             &lt;activation&gt; 
  51.                 &lt;status&gt;&lt;/status&gt;
  52.                 &lt;prodactkey&gt;&lt;/prodactkey&gt;
  53.             &lt;/activation&gt;
  54.             &lt;subscription&gt;
  55.                 &lt;status&gt;&lt;/status&gt;
  56.                 &lt;serialnum&gt;&lt;/serialnum&gt;
  57.             &lt;/subscription&gt;
  58.  
  59.         &lt;/product&gt;
  60.     &lt;/products&gt; 
  61.     &lt;ocssession&gt;
  62.         &lt;contact&gt;
  63.             &lt;method&gt;contactEmail&lt;/method&gt;
  64.             &lt;filter&gt;order_billing&lt;/filter&gt;
  65.         &lt;/contact&gt;
  66.     &lt;/ocssession&gt;
  67.     &lt;/ticket&gt; ">
This is the code i am using

what are the other methods can i parse this xml string apart from using the simplexml load string method.

Regards,
Anubhav
Aug 5 '08 #7
pbmods
5,821 Expert 4TB
I see from the source of your post that you are correctly-escaping the XML, so that's not an issue.

Given the size of the string, I'd strongly recommend saving the XML as a session variable.

But if you absolutely have to pass it through the form, strip out all the newlines (and probably whitespace as well just for good measure). Something along the lines of:

Expand|Select|Wrap|Line Numbers
  1. $xml = str_replace(array("\r", "\n", "\t", ' '), '', $xml);
  2.  
Aug 5 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: James Johnson | last post by:
Dear C#Dex, I am trying to automate a POST to a web page that clicks a button. I have been able to hit a target web page and run the web page. However, the button on the page does not click. ...
5
by: Tammy | last post by:
Hi, I have an aspx app which needs to post data to a form and read the response. I am confused on whether I should be using the get_url using "POST" method or the post_url using "GET" method. ...
6
by: someone | last post by:
I am in a situation where I need to package some information from Page1, submit it via POST to another server which will process the information and then send the user to another page on my server...
1
by: Dave Brown | last post by:
I am attempting to post to a url (https://FakeURL/logon.asp) using the HttpWebRequest class. The response for a succesful post will contain the html for the logon user's default page. We've...
0
by: Owen | last post by:
Hello everyone, I am using VS.NET 2003(Trandition Chinese) Edition, and httpLook software for checking http requests. I found a problem that the following programs don't really "POST". These...
2
by: Ben | last post by:
Hi I have the two funcions below, login_web that posts data to a webpage and fcn_parseviewstate that parses the viewstate data for the post. I have a problem with the strPostData, I have been...
0
by: WIWA | last post by:
Hi, I want to login to a password protected website and fetch the content of the page behind. I have based my code on http://weblogs.asp.net/jdennany/archive/2005/04/23/403971.aspx. When I use...
1
by: arfeengodil | last post by:
Hi, I need to have a web application such that other applications should be able to do send data to it using HTTP Post. So I created a ASP.NET web service and defined a web method for other...
7
by: php_mysql_beginer911 | last post by:
Hi .. hope someone will help i am trying to figure it out why i cannot post string "union select" every time i try to post data which content union and select .. the page doesn't get posted and...
6
by: CindyH | last post by:
Hi I'm not sure whether I should send this as a new message or use the one I've been using but... I'm using vb.net 2.0 - My problem is I need to send something like this: 'dim encodedstring =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.