Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
iGanja
Posts: 6
Registered: ‎01-03-2009
Accepted Solution

How to render xml on browser?

using Storm browser AND simulator, both give the same results.

i have read that AJAX is support in the browser and i have verified that the XLHttpRequest object does indeed work.

however, the X in AJAX stands for XML, and i have yet to get the browser to render an XML stream without the following error: "A problem occurred while trying to render the page"

here is a sample of the XML i am trying to return:

 

<?xml version="1.0" encoding="utf-8" ?>

<Routes><

Route>

<ActivityID>f254339a</ActivityID><

ActivityName>Cycling</ActivityName>

<RouteID>506c3599</RouteID><

RouteName>SantigoCanyon</RouteName>

</Route>

</Routes>

 

I am also sending the ContentType "text/xml" in the header.

This works flawlessly in every normal browser i have tried.

I am seriouly ready to throw something, please give me some ideas.

 
Please use plain text.
Developer
Posts: 107
Registered: ‎09-25-2008

Re: How to render xml on browser?

As far as I know the BlackBerry browser doesn't support rendering of plain XML. There isn't a standard rendering defined for XML anyhow; you usually have to use XSL or CSS to style the elements and make it look like something.
Please use plain text.
Guru I
Xandrex
Posts: 18,375
Registered: ‎07-29-2008
My Carrier: Vodafone France (SFR) & B&You

Re: How to render xml on browser?

your XML file has no DTD to validate the XML file. There is no CSS to tell the Blackberry browser how to render it.
Besides, using text/xml is not recommended at all even though it is allowed : http://www.w3.org/TR/xhtml-media-types/
you should really try and use application/xhtml+xml



The search box on top-right of this page is your true friend, and the public Knowledge Base too:
Please use plain text.
New Developer
iGanja
Posts: 6
Registered: ‎01-03-2009

Re: How to render xml on browser?

Thank you both for your responses. btw, there is no DTD for straight xml as there is only the version "1.0" standard, so there is no reason to validate it any other way.  In my case, i couldn't care less how the xml is rendered what i am doing is behind the scenes using the XMLHttpRequest object in an AJAX call.

 

However, changing my contentType to application/xhtml+xml did in fact get the xml to render as text on the browser, but it didn't matter.  After further review, it appears, i am indeed getting the xml through the XMLHttpRequest object - no matter what contentType i use.  My problem now is i am unable to parse it.  I am using the standard JavaScript DomParser() object, but i get nothing out of it.

 

any help with this is greatly appreciated.

 

thanks,

 

Please use plain text.
Developer
Posts: 107
Registered: ‎09-25-2008

Re: How to render xml on browser?

[ Edited ]
How are you using the DomParser object - do you have sample code?

Also, have you tried using the .responseXML property of the XMLHttpRequest object? That will give you a parsed Document so you don't have to parse it yourself.

http://www.w3.org/TR/XMLHttpRequest/#responsexml
Message Edited by staktrace on 2009-01-03 06:51 PM
Please use plain text.
New Developer
iGanja
Posts: 6
Registered: ‎01-03-2009

Re: How to render xml on browser?

yes, that ended up being my problem. i was using the responseText property from an earlier project where i was doing more html injection rather than xml and had written a function to create am xml document - when needed - from the text using the DomParser object which blackberry doesn't support. so using the responseXML property instead allows me to parse it directly.

 

so, i finally got a simple drop down populated with data, 18 hours later...

 

thanks

Please use plain text.
New Developer
yreik
Posts: 5
Registered: ‎01-16-2009

Re: How to render xml on browser?

Hello,

I am using the responseXML property but I am getting it as null. responseText property has the proper response in the String format. But I need the xml in responseXML so I can use it directly. The jsp serving the response

is setting the contentType as "text/xml" and it is working fine in Internet Explorer. But in blackberry browser in Blackberry 9530 simulator this is not working. I also tried using the DOMParser but as you mentioned earlier, that doesn't seem to be supported in blackberry yet. The XML structure is like this:

<?xml version="1.0" encoding="utf-8" ?>
                        <responseMsg>
                            <node1><%=node1%></node1>
                            <node2><%=node2%></node2>
                        </responseMsg>

 

 

Any idea what could be the issue?

Please use plain text.
Guru I
Xandrex
Posts: 18,375
Registered: ‎07-29-2008
My Carrier: Vodafone France (SFR) & B&You

Re: How to render xml on browser?

the W3C recommends not using text/xml but application/xhtml+xml

http://www.w3.org/TR/xhtml-media-types/



The search box on top-right of this page is your true friend, and the public Knowledge Base too:
Please use plain text.
New Developer
yreik
Posts: 5
Registered: ‎01-16-2009

Re: How to render xml on browser?

Thanks for your response. I changed the contentType to application/xhtml+xml but I am still getting null in responseXML property.

Please use plain text.
New Developer
iGanja
Posts: 6
Registered: ‎01-03-2009

Re: How to render xml on browser?

[ Edited ]

perhaps you could post your code that creates your XMLHTTPRequest object?

and/or the code you are using to parse your xml?

Message Edited by iGanja on 01-16-2009 01:50 PM
Please use plain text.