General

Reply
Accepted Solution

Xml handling / parsing, remote, URL, download, Http Get / Post

Well this is a rather noobish question, but I hope this could help others in the future, who want to download stuff from the web and eventually parse it (or process it any other way).

 

How would it be done the right way regarding the SDK; for instance when someone would like to deserialize XML content and work with it like a domain model?

 

I would be very grateful to get any feedback for my approach: Pastebin Sample

 

Is there anything that you'd done differently? Is my sample absurdly wrong and shouldn't be used in any case?

 

 

Thanks in advance for all feedback. :Smile:

Please use plain text.

Re: Xml handling / parsing, remote, URL, download, Http Get / Post

I've searched the docs and I didn't find anything about XML. I haven't tried anything about this yet. Maybe you can use standard .Net libraries.
Please use plain text.

Re: Xml handling / parsing, remote, URL, download, Http Get / Post

Yes there's luckily a good C# XML library included in the SDK and my sample uses exactly that.

I also took the HttpSample and modified it to get the desired result.

 

But I still wonder if I've done it right considering the "Playstation Suite" framework and it's domain. Am I using the main loop correctly? Does this approach result in any major limitation regarding GUI, etc.?

 

I'm just curious if it's the right way to go, because I'd continue using that approach and build my small app around that for the beginning. :-)

Please use plain text.

Level 2

Level 2
mdiza
Posts: 12
Registered: ‎27-12-2011
Message 4 of 5 (388 Views)

Re: Xml handling / parsing, remote, URL, download, Http Get / Post

When it comes to XML there are many ways to skin a cat.

 

I do not see anything wrong with the approach you have taken.    It uses the XML deserializer, which will work for many kinds of XML formatted content.   As long as you control both the generation and the consumption side you wont have a problem.

 

If you were to process a third-party XML, it might very well be the case that you can not map the XML schema to the limited schema supported by the Xml Serializer (which was really designed for Document/Literal encoding).

 

If that is the case, you might have to resort to either using a streaming parsing API (XmlReader) or using the in-memory modules (the sexy XDocument or the old and busted XmlDocument).

 

That said, when it comes to trasfering data to these devices, keep in mind that you might be running on a pretty bad network connection.  That the user might be moving from his WiFi at home to a 3G on the road and might even hit spots with bad reception.   

 

This means that you should try to make the data that is exchanged as small as possible.

 

Try to use gzip compression on the server, and force your client code to request Gzip transfers (see my TweetStation code on GitHub to see how I force Twitter to send me Gzip data).   

 

You might also want to go with Json for encoding, as this is a lighter protocol.


In fact, if you want lighter, you might want to consider protocol buffers.

 

Miguel

Miguel de Icaza -- miguel@xamarin.com
Please use plain text.

Re: Xml handling / parsing, remote, URL, download, Http Get / Post

That's a really nice and detailed answer, huge thanks and many thumbs up for it, really really helpful stuff. :Smile:

Please use plain text.
This widget could not be displayed.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.

フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと PSM DevPortalを一度ログアウトし、再度ログインしてください。






Recent News