Jump to content

Recommended Posts

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

&ltcorecom:Name&gtDemo&lt/corecom:Name&gt

 

The "<" and ">" symbols are getting replaced by "&lt" and "&gt"

 

Thanks...

 

Link to comment
https://forums.phpfreaks.com/topic/152744-xml-data/
Share on other sites

The "<" and ">" symbols are getting replaced by "&lt" and "&gt"

 

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..........

Link to comment
https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802124
Share on other sites

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."

Link to comment
https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802150
Share on other sites

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'>

----------^

Link to comment
https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802186
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802205
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802209
Share on other sites

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;

 

Link to comment
https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802228
Share on other sites

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 &lt,&gt.

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.

 

Link to comment
https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-802247
Share on other sites

@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!..

Link to comment
https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-803929
Share on other sites

@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...

 

 

Link to comment
https://forums.phpfreaks.com/topic/152744-xml-data/#findComment-805345
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.