Solved

XML Closing Tags

Posted on 2012-12-25
16
474 Views
Last Modified: 2013-02-05
Hello,
I am constructing XML to make a web service call. I close one of the tags like this:
<tagname isNull="false" />
When I look at the Generated Source (Firefox), it has ignored the closing tag and has generated </tagName>.
For example,
<tag1>
    <tag2>Some Value</tag2>
    <tag3 isNull="false" />
   <tag4>Some other Value</tag4>
</tag1>
becomes
<tag1>
    <tag2>Some Value</tag2>
    <tag3 isNull="false">
   <tag4>Some other Value</tag4>
    </tag3>
    <tag3 isNull="false"></tag3>
</tag1>

Any help is appreciated!
Thanks
0
Comment
Question by:perlwhite
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 2
  • +1
16 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 100 total points
ID: 38720618
Firebugs adds missing tags on it's own. Make sure that you look at the HTML with the browser's "View Source" feature

refer - here is same answer
http://stackoverflow.com/questions/3355507/php-stop-closing-tag-being-automatically-added
0
 

Author Comment

by:perlwhite
ID: 38720636
My View Source is showing the current XML. However, I am still getting an error from the web service. Is there anything else that I am overlooking?
0
 
LVL 11

Expert Comment

by:mcnute
ID: 38720993
Are you declaring your xml document as standards are requiring?

<?xml version="1.0"?>

Open in new window

0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 110

Expert Comment

by:Ray Paseur
ID: 38721064
... it has ignored the closing tag ...
What is "it" in that statement?  How exactly are you constructing the XML document?
0
 

Author Comment

by:perlwhite
ID: 38721117
It is the generated source.

The web service does not require the <?xml ... tag.

I am constructing xml in a php variable which is then passed to the web method.

$param = '<tag1>';
$param .= .....

I am constructing xml in the same fashion for another web method from the same web service provider and it works flawlessly.
0
 
LVL 11

Expert Comment

by:mcnute
ID: 38721123
Try to construct the variable with double quotes instead of single quotes.

Single quotes could mess up new lines (eol).
0
 

Author Comment

by:perlwhite
ID: 38721131
I believe I tried that but will try it again. Thanks
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 38721272
I want to deconstruct this a little bit (copied from the original question).  How does this happen?  What process is changing the XML document (the becomes verb)?  These documents are not very much alike at all - in meaning or content.

For example,
<tag1>
    <tag2>Some Value</tag2>
    <tag3 isNull="false" />
   <tag4>Some other Value</tag4>
</tag1>
becomes
<tag1>
    <tag2>Some Value</tag2>
    <tag3 isNull="false">
   <tag4>Some other Value</tag4>
    </tag3>
    <tag3 isNull="false"></tag3>
</tag1>

Open in new window

0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 100 total points
ID: 38721279
Please see http://www.laprbass.com//RAY_temp_perlwite.php to visualize the differences between these XML documents.
<?php // RAY_temp_perlwite.php
error_reporting(E_ALL);
echo '<pre>';

// DOCUMENT 1
$xml = <<<ENDXML
<tag1>
    <tag2>Some Value</tag2>
    <tag3 isNull="false" />
   <tag4>Some other Value</tag4>
</tag1>
ENDXML;
$obj = simplexml_load_string($xml);
var_dump($obj);

echo PHP_EOL;

// DOCUMENT 2
$xml = <<<ENDXML
<tag1>
    <tag2>Some Value</tag2>
    <tag3 isNull="false">
   <tag4>Some other Value</tag4>
    </tag3>
    <tag3 isNull="false"></tag3>
</tag1>
ENDXML;
$obj = simplexml_load_string($xml);
var_dump($obj);

Open in new window

WTF comes to mind ;-)
0
 

Author Comment

by:perlwhite
ID: 38721342
View Source in Firefox shows the correct XML. View Generated Source in Firefox shows the incorrect XML.
0
 

Author Comment

by:perlwhite
ID: 38721345
Thank you Ray for the visualization
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 38721372
That sounds like the problem might be in Firefox.  If your program code is creating a valid XML document, it doesn't seem like FF is rendering it correctly with View Generated Source.
0
 

Author Comment

by:perlwhite
ID: 38737885
I sent the XML using the WCFStorm tool and I get a successful response.

I took the exact same XML and sent it via PHP and I get the "Object reference not set to anything" error.
$arg = 'XML sent using WCFStorm tool';
$c->call('Method Name', $arg);
I am using nusoapclient and Zend
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 38738496
Sorry -- if it's SOAP I have to sign off.  Nothing personal, but SOAP is an impossibly bad protocol, and now that I know it's SOAP, I can accept any outcome, no matter how ridiculous, as plausible.  Ask the publishers if they have a RESTful interface and use if it they do.  It will most likely work correctly and intuitively the first time.  If they do not have a REST interface, ask them for a PHP example using SOAP.  I wish I could be of some help, but life is too short to use and debug SOAP.  It's like being a blind man in a knife fight.
0
 

Author Comment

by:perlwhite
ID: 38796591
They don't have a RESTful interface. I am required to use SOAP. Can someone help?
0
 

Author Comment

by:perlwhite
ID: 38857924
Please ignore the delete request. I have accepted 2 answers as solutions.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question