Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by RalliantoDeLaVega · Sep 13, 2015 at 02:46 PM · stringxmlconvertuniversalhtml

Convert XML/HTML from RSS feed into something usefull?

I'm building an Windows Universal App for a Raspberry Pi 2. I used the System.Data-library (DataSet) for interpretation of this kind of info:

 <?xml version="1.0" encoding="utf-8"?>
 <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
         <title>TV 2 - alle nyheder</title>
         <description>Nyheder fra tv2.dk</description>
         <link>http://tv2.dk</link>
         <lastBuildDate>Sun, 13 Sep 2015 14:30:23 GMT</lastBuildDate>
         <docs>http://blogs.law.harvard.edu/tech/rss</docs>
         <image>
             <title>TV 2 - alle nyheder</title>
             <url>http://tv2.dk/profiles/tv2/modules/custom/t2zerowing/pkg/img/apple-touch-icon-precomposed.png</url>
             <link>http://tv2.dk</link>
         </image>
         <copyright>Copyright © TV 2 DANMARK A/S. All rights reserved</copyright>
         <generator>Feed for Node.js</generator>
         <item>
             <title><![CDATA[DF hiver Søren Pind i samråd om flygtningesituation]]></title>
             <link>http://politik.tv2.dk/2015-09-13-df-hiver-soeren-pind-i-samraad-om-flygtningesituation</link>
             <guid>http://politik.tv2.dk/node/68459</guid>
             <pubDate>Sun, 13 Sep 2015 14:25:51 GMT</pubDate>
             <description><![CDATA[<p><img src="http://drupal-images.tv2.dk/sites/images.tv2.dk/files/t2img/2015/09/13/960x540/168641983-20150618-220158-L.jpg" alt="" /></p><p>Dansk Folkeparti vil have justitsministeren til at redeg&oslash;re for flygtningesituationen, som de kalder kaotisk.</p>
 
 <p>Dansk Folkeparti kr&aelig;ver nu justitsminister S&oslash;ren Pind (V) i samr&ar...</p>]]></description>
             <content:encoded><![CDATA[-]]></content:encoded>
             <author>
                 <name>Ritzau</name>
             </author>
         </item>
         <item>
             <title><![CDATA[TV 2 LIVECENTER: Tyskland vil indføre grænsekontrol]]></title>
             <link>http://nyhederne.tv2.dk/2015-09-12-tv-2-livecenter-tyskland-vil-indfoere-graensekontrol</link>
             <guid>http://drupal-nyhederne.tv2.dk/node/861893</guid>
             <pubDate>Sun, 13 Sep 2015 14:24:57 GMT</pubDate>
             <description><![CDATA[<p><img src="http://drupal-images.tv2.dk/sites/images.tv2.dk/files/t2img/2015/09/12/960x540/168197093-25658936-TV%202%20LIVECENTER.png.jpg" alt="" /></p><p>TV 2 Nyhederne giver dig dagens historier i TV 2 LIVECENTER.</p>
 ]]></description>
             <content:encoded><![CDATA[-]]></content:encoded>
             <author>
                 <name>Jakob Binderup</name>
             </author>
         </item>

But now that I'm targeting Universal App, I get lots of compile errors, because the assemblies I added myself (System.Data, and a few others) won't compile to Universal App, because they are not supported. Do any of you guys know a quick and handy way to somehow convert this XML/HTML kinda info into strings? NOTICE: In the "description" attribute is BOTH located the URL for the image, AND the main text, which I would like to get separated

Rasmus

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RalliantoDeLaVega · Sep 13, 2015 at 05:33 PM 0
Share

I found that i can use System.Xml. I'm trying to figure out how to extract "title" and "description" from each item (Look at the X$$anonymous$$L code snippet above). I'm trying this:

 public void ReadX$$anonymous$$L(WWW www)
      {
          xmlDoc = new XmlDocument();
          xmlDoc.LoadXml(www.text);
  
          foreach (XmlElement node in xmlDoc.SelectNodes("Item"))
          {
              Debug.Log("I was called !!!!!!!!");
              RSSItem rssItem = new RSSItem();
              rssItem.title = node.SelectSingleNode("title").InnerText;
              rssItem.description= node.SelectSingleNode("description").InnerText;
          }
      }

But i don't even enter the foreach-loop. Any of you guys know how to extract "title" and "description" ?

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by OJ3D · Jan 24, 2016 at 04:07 PM

Found the sleekest answer for Rss feeds (see the link below). The unity package is provided for free too.

http://forum.unity3d.com/threads/rss-reading-into-unity-example.61332/

I made several attempts at the deserialization efforts and it would only partially come through. I have a feel it had something to do with the RSS element as a XLMroot or something like that. Anyway, the package above is still relevant and easily modifiable. Also, make sure you're URL to your xml file doesn't have a "https" but make sure it's "http". For some reason it didn't place nicely with the security protocol version.

OJ

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by j0ffe · Sep 13, 2015 at 03:42 PM

Their is a lot of XML serialize out their.

This one for example: http://www.codeproject.com/Articles/34045/Yet-Another-XML-Serialization-Library-for-the-NET

Which one is best for your work is probably only you that knows.

Search for C# XML library and you will get tons of results.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

29 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

c# convert int to string 2 Answers

Converting String to a Game Object 1 Answer

html links in strings or GUI components possible? 1 Answer

Parseing Varible names from strings 1 Answer

Simple XML reading? (only string/numerical data needed) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges