Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what's wrong with this XML

Status
Not open for further replies.

tomih

Programmer
Sep 23, 2003
13
SI
Hi!

Can anybody, please, tell me what's wrong with this XML:
NOTE: tags within CONTENT tag are properly encoded ie: &some_code;

Code:
<?xml version=&quot;1.0&quot; ?>
<root>
<content><IMG height=15 src=&quot;[URL unfurl="true"]http://vaio/cmpro/sites/linia-gradiani/images//images/spacer.gif&quot;[/URL] width=1><BR>
<TABLE cellSpacing=0 cellPadding=0 width=&quot;100%&quot;>
<TBODY>
<TR>
<TD width=31><IMG height=13 src=&quot;[URL unfurl="true"]http://vaio/cmpro/sites/linia-gradiani/images//bg_tl.gif&quot;[/URL] width=31></TD>
<TD class=naslov><SPAN id=tpl_str_title contentEditable=false>Testni asdfsadf naslov</SPAN></TD></TR>
<TR>
<TD width=31><IMG height=3 src=&quot;[URL unfurl="true"]http://vaio/cmpro/sites/linia-gradiani/images//bg_ml.gif&quot;[/URL] width=31></TD>
<TD><IMG height=3 src=&quot;[URL unfurl="true"]http://vaio/cmpro/sites/linia-gradiani/images//bg_mr.gif&quot;[/URL] width=321></TD></TR>
<TR>
<TD vAlign=top width=31><IMG height=274 src=&quot;[URL unfurl="true"]http://vaio/cmpro/sites/linia-gradiani/images//bg_bl.gif&quot;[/URL] width=31></TD>
<TD class=tekst vAlign=top><IMG height=15 src=&quot;[URL unfurl="true"]http://vaio/cmpro/sites/linia-gradiani/images//images/spacer.gif&quot;[/URL] width=1><BR><SPAN id=tpl_str_content contentEditable=false>
<P>vsesadfasdfasdfbina</P>
<P><IMG src=&quot;[URL unfurl="true"]http://vaio/cmpro/sites/linia-gradiani/images/Slike/1.jpg&quot;></P>[/URL]
<P>kasdm fokmaosdfm laksmdf lkmas dfkm lasdmf</P>
<P>asokmf alskdmf laksmdflkasmdflkasmdf lkma sldkmf </P>
<P>aksmdflkmas dkfm asldmflaksdmf asdf</P>
<P>apskdmf lasdmf laksmd flaksmd f</P>
<P>oaskmdf laskmdf laksmdflaksmdf </P>
<P>
<TABLE class=&quot;&quot; style=&quot;WIDTH: 180px; HEIGHT: 180px&quot; cellSpacing=3 cellPadding=1 border=1 maxcols=&quot;2&quot;>
<TBODY>
<TR>
<TD>weqwe</TD>
<TD>qwer</TD>
<TD>qwer</TD>
<TD>qwerwer</TD></TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR></TBODY></TABLE></P></SPAN></TD></TR></TBODY></TABLE></content>
<short_title>test</short_title>
<page_title></page_title>
<page_description></page_description>
<sql_id>21</sql_id>
<page_keywords></page_keywords>
<active>-1</active>
<in_menu>-1</in_menu>
<pageType>vsebina</pageType>
<redirect></redirect>
<title></title>
<templates>vsebina1.html,vsebina2.html</templates>
<layout>vsebina1.html</layout>
<templates_dir>/cmpro/admin/sites/linia-gradiani/templates/vsebina</templates_dir>
</root>

I know the problem is in CONTENT tag, but don't know what!? Is there some wrong char?

Thnx,
t.

Tomi Hrovatin
 
Just to begin with...
[tt]
<IMG height=15 src=&quot; &quot; width=1><BR>
[/tt]
XML (unlike HTML) expects the IMG and BR tags to be closed somewhere, or to have a trailing / to indicate an empty element. It also expects all attribute values to be enclosed in quotes. So your <content> should start
[tt]
<IMG height=15 src=&quot; &quot; width=&quot;1&quot; /><BR />
[/tt]
Incidentally, if you're storing all that HTML formatting code in your XML document you're probably missing the point. Design the XML to reflect your data structure and use XSL or some programming to translate it into suitably formatted HTML.

-- Chris Hunt
 
Thnx for your answer, but I don't think that is a problem since all tags in XML content tag (table, tr, img, ...) are encoded with &some_code;. So, there is no reason they are interpreted like a tag or to interpret arguments like tag arguments.
I just tried it again on different computer (the code trying to read xml is on client side-IE) and it works just fine. Both IEs are version 6.0.2800.1106 but one (the one wich works) have more Update versions installed.

Since this is intended to be a client administration console, it's not exceptable to do errors on every second computer.

Any ideas what to do?

T.



Tomi Hrovatin
 
Is there some wrong char?

If you're showing us code that's already been interpreted, how could we tell?
 
>> Just for info: I use Msxml2.DomDocument on server side
>> (asp) to create xml which is called by client jscript.

That's a clear as mud.

>>NOTE: tags within CONTENT tag are properly encoded ie: &some_code;

Then we would need that version to help, right? Or am i missing something?

-pete
 
Ok I have validated that the xml is well formed. Both with XML Spy and Microsoft IE (MSXML4). Therefore it seems to me the next bit of information we will need is what are you doing to it when and how using what.

Your previous posts mention ASP and client side Jscript with no details as to what that code is doing with this XML data. Nor have you posted any sort of actual error message that is being generated by <whatever>.

This is a technical forum right? I have not stumbled into a forum for magicians have I?


-pete
 
ok. This is an xml for generating html pages.
The client side is writen in jscript and goes like this:

Code:
http = new ActiveXObject( 'Msxml2.XMLHTTP' );
http.open( 'GET', url, true );
http.onreadystatechange = function() {
  if( http.readyState == 4 ) {
  var doc = http.responseXML;
  doc.setProperty( 'SelectionLanguage', 'XPath' );
  alert(doc.documentElement); //here comes error: doc.documentElement is null in some cases
}
}

and here comes the server side code which generates xml:
Code:
var doc = new ActiveXObject( 'Msxml2.DomDocument' );
doc.loadXML( '<root/>' );

var e = doc.createElement( 'content' );
e.text = &quot;content...&quot;;
doc.documentElement.appendChild( e );

var e = doc.createElement( 'short_title' );
e.text = &quot;short_title...&quot;;
doc.documentElement.appendChild( e );
...

Response.contentType = &quot;text/xml&quot;;
Response.Write(&quot;<?xml version=\&quot;1.0\&quot; ?>&quot;);
Response.Write(doc.xml);

note:
-in some cases the xml works and the difference is only in content tag. But I can't find the 'wrong' char which is causing an error. I tried with different HTML tags within content tag.

-all this code works on one computer but it doesn't work on other.
The working computer: win2000pro, IE 6.0.2800.1106,
non-working one: win2000server, IE 6.0.2800.1106 with some less Update versions installed.



T.

Tomi Hrovatin
 
So the client side code runs in the browser. Have you tried adding a HTML <textarea> to the page? Upon your Jscript finding the error you indicated in your post, the Jscript takes the http response text and set it as the value for the <textarea>. That way when the XML is not valid you can get at the raw text of the response and analyze it using another tool to find the XML error.

-pete
 
hi to everybody,

First understand the what is XML. XML is a Well structured document. I am answering to the first thread mentioning &quot;what's wrong with the xml file&quot;. In XML file,

1. All the attributes should be enclosed either in double quotes or single quotes.

2. All the elements(tags) should have mandatory closing tag or it should have orphan tag (e.g. <br/>)

you said that some XML elements are encoded as &somecode, but you did not declared a DTD in the XML file.



 
Hmm, note that the client-side code includes
Code:
http = new ActiveXObject( 'Msxml2.XMLhttp' );

Perhaps the reason it works on some machine and not others is that msxml2.dll is old. I believe that machines with IE6 installed would be up to version msxml4. There are significant changes.

Give it a shot.

HTH,
harebrain
 
Hi again,

guys, thnx for all your opinions, but none solved the problem, since there was NO problem at all. The error was caused by IE 6. Today everything works on both computers. Yesterday I used single explorer window for a whole day.
I will check all the code for object disposals and memory usage etc.
If I get more info on what caused the error, I will post on forum.

thnx again,

T.

Tomi Hrovatin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top