umishra Posted April 6, 2009 Share Posted April 6, 2009 Hi All, I am a newbie in PHP and I am stuck up on an issue... I am using a tool based in PHP. I have added some steps to a tests.These steps are in the XML format.An example of one being given below. <corecom:Name>Demo</corecom:Name> Now,on submittinghat this steps to the browser and viewing it,the result shown is just shown as Demo. The xml tags are not visible. On checking in the Database,the column value is <corecom:Name>Demo</corecom:Name> While retrieving the data on the browser,the tags are not visible... On checking the view source,i can see the xml tags <corecom:Name>Demo</corecom:Name> I have included the below string in my php file htmlentities($step_action, ENT_COMPAT); But this solves half the problem. Now,when I am adding these steps from the browser,the tags are visible. But when importing an excel sheet containing the same xml tag,it shows as <corecom:Name>Demo</corecom:Name> The "<" and ">" symbols are getting replaced by "<" and ">" Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/ Share on other sites More sharing options...
Daniel0 Posted April 6, 2009 Share Posted April 6, 2009 The "<" and ">" symbols are getting replaced by "<" and ">" You did that yourself... Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802105 Share on other sites More sharing options...
umishra Posted April 6, 2009 Author Share Posted April 6, 2009 The "<" and ">" symbols are getting replaced by "<" and ">" You did that yourself... If I remove the htmlentities($step_action, ENT_COMPAT); then the tags are visible when importing from the excel sheet. But they are not visible when added from the browser directly... Please help.......... Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802124 Share on other sites More sharing options...
Daniel0 Posted April 6, 2009 Share Posted April 6, 2009 Well, you're not the one reading it, are you? If you want to read it then serve it as application/xml like you're supposed to do for XML data. A page will default to text/html in a web browser, but yours isn't HTML, so of course it'll not look right. Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802137 Share on other sites More sharing options...
umishra Posted April 6, 2009 Author Share Posted April 6, 2009 Well, you're not the one reading it, are you? If you want to read it then serve it as application/xml like you're supposed to do for XML data. A page will default to text/html in a web browser, but yours isn't HTML, so of course it'll not look right. Could you please elaborate on this. I am the one reading it.Could you explain " If you want to read it then serve it as application/xml like you're supposed to do for XML data." Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802150 Share on other sites More sharing options...
Daniel0 Posted April 6, 2009 Share Posted April 6, 2009 header('Content-type: application/xml'); Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802160 Share on other sites More sharing options...
umishra Posted April 6, 2009 Author Share Posted April 6, 2009 header('Content-type: application/xml'); On adding the above,get the following error: XML Parsing Error: not well-formed Location: http://*************/rth_1.6.1/test_detail_page.php?test_id=11231 Line Number 6, Column 11:<link rel=stylesheet type='text/css' href='./css/default.php'> ----------^ Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802186 Share on other sites More sharing options...
Daniel0 Posted April 6, 2009 Share Posted April 6, 2009 I thought it was an XML document? Which is it, HTML or XML? You can't just mix it like you're doing. Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802195 Share on other sites More sharing options...
umishra Posted April 6, 2009 Author Share Posted April 6, 2009 I thought it was an XML document? Which is it, HTML or XML? You can't just mix it like you're doing. I am working on RTH tool which is based on php platform. The piece of code which will be reflected in the browser is foreach($rows_test_steps as $row_test_step ) { $row_test_step_id = $row_test_step[TEST_STEP_ID]; $step_number = $row_test_step[TEST_STEP_NO]; $step_action = $row_test_step[TEST_STEP_ACTION]; $step_test_inputs = $row_test_step[TEST_STEP_TEST_INPUTS]; $step_expected = $row_test_step[TEST_STEP_EXPECTED]; $info_step = $row_test_step[TEST_STEP_INFO_STEP]; Here,i want to read to read $step_action.The tool has an option to view TEST_STEP_ACTION in the browser. It has an option to add it from the browser itself.Suppose,I want to enter the following in the browser against the Action column: <corecom:Name>Dev24</corecom:Name> <corecom:ClassificationCode listID="PType"/> <corecom:ClassificationCode listID="BPType">DEFAULT</corecom:ClassificationCode> <corecom:ClassificationCode listID="FItem"/> <corecom:ServiceIndicator>false</corecom:ServiceIndicator> <corecom:TypeCode>'OFFER'</corecom:TypeCode> <corecom:Description>'Dev24</corecom:Description> If the above scenario is carried out,the tags are not visible. Now,when I import an excel sheet(the tool has this option) containing the above steps,the tags are visible. I hope...I am getting across to you... Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802205 Share on other sites More sharing options...
Daniel0 Posted April 6, 2009 Share Posted April 6, 2009 Well, "visible", how exactly are you outputting it? You can't just echo raw XML in the middle of an HTML document. When an HTML parser is parsing an HTML document, it'll just throw away unknown tags and attributes. What you are seeing is the rendered version, and what you see when you when you click "view source" is the raw source code. Programs that'll read your outputs reads the source, not whatever it has turned into graphically when it's been rendered. Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802209 Share on other sites More sharing options...
umishra Posted April 6, 2009 Author Share Posted April 6, 2009 Well, "visible", how exactly are you outputting it? You can't just echo raw XML in the middle of an HTML document. When an HTML parser is parsing an HTML document, it'll just throw away unknown tags and attributes. What you are seeing is the rendered version, and what you see when you when you click "view source" is the raw source code. Programs that'll read your outputs reads the source, not whatever it has turned into graphically when it's been rendered. I am outputting it as print"<td align=left><div $info_step_class>$step_action</div></td>". NEWLINE; Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802228 Share on other sites More sharing options...
Daniel0 Posted April 6, 2009 Share Posted April 6, 2009 Then just do print"<td align=left><div $info_step_class>". htmlentities($step_action) . "</div></td>". NEWLINE; I don't see why that would interfere with Excel though. How is it being read into that? (And why do you put XML data in Excel?) Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802234 Share on other sites More sharing options...
umishra Posted April 6, 2009 Author Share Posted April 6, 2009 Then just do print"<td align=left><div $info_step_class>". htmlentities($step_action) . "</div></td>". NEWLINE; I don't see why that would interfere with Excel though. How is it being read into that? (And why do you put XML data in Excel?) Doesn't work. Get corrected for the steps added.But the xml tags imported using excel,is replaced by <,>. XML data is being put into Excel,as these are the test-steps which are part of a test-case. The users will input xml data into the excel sheet. Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802247 Share on other sites More sharing options...
Daniel0 Posted April 6, 2009 Share Posted April 6, 2009 Yeah, but how exactly is it "imported"? You'll probably have to rethink the design of your application to have a page that solely provides the XML data. Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802272 Share on other sites More sharing options...
umishra Posted April 6, 2009 Author Share Posted April 6, 2009 Yeah, but how exactly is it "imported"? You'll probably have to rethink the design of your application to have a page that solely provides the XML data. There is another php file which imports this excel file. Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802372 Share on other sites More sharing options...
Daniel0 Posted April 6, 2009 Share Posted April 6, 2009 Then why is it a problem to escape the entities on the file you're viewing? Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802383 Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 @umishra, Considering Daniel is very well versed in the formatting of data, might I recommend you Describe the goal, not the step as you may be trying to do something that will never work! What do you have and what do you want at the end.. and how are you trying to get their, From what you have said so far.. its very confusing, why your trying to mix format types!.. Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-803929 Share on other sites More sharing options...
umishra Posted April 9, 2009 Author Share Posted April 9, 2009 @umishra, Considering Daniel is very well versed in the formatting of data, might I recommend you Describe the goal, not the step as you may be trying to do something that will never work! What do you have and what do you want at the end.. and how are you trying to get their, From what you have said so far.. its very confusing, why your trying to mix format types!.. @MadTechie. I would keep in mind what u mentioned and try explaining what exactly is my goal. @Daniel. I want to read the xml tags,as it is,in the browser.I am using the RTH tool which is based on PHP. But I am unable to do so... Quote Link to comment https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-805345 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.