Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by DaveA · Apr 19, 2011 at 08:08 PM · optimizationwwwxmlparse

Parsing large XML files on-the-fly, best practice?

I need to periodically (like every 10 seconds) parse an XML file I get via WWW. Using System.Xml and XmlDocument. When the file is small, it's fine, but larger ones give a noticeable pause in frame rendering. I'm doing it on an Update call. I know, I know, bad.

So what's a better way? Should I just do what I do, but in a coroutine? Different thread (if so, any good examples)? Or is there an XML parser implementation that can 'spread' its work out over multiple frames?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bunny83 · Apr 19, 2011 at 08:32 PM

Well, a coroutine wouldn't make any difference since it's called within the Unity update-loop and a single task can't be interrupted. A different thread would be a way but if it's really much data it can influence the main thread as well (like every other thread).

I've never had a xml parser that support "suspending" in between. If there is one that would be great ;). Another solution would be to write your own parser. XML is not that hard to parse. What data you need? If it's just a subset, the parser don't need to "unwrap" the whole file into nodes. It would be enough to parse through the stream and just wait for the right node.

If you write your own parser you could implement your own time-watchdog that yields if a certain amount of time has passed.

When writing your own parser you have to think about if you want a "general" parser or one that fits your needs in this case. Does the xml file contain CDATA sections? Without those it gets really simple ;)

Comment
Add comment · Show 1 · 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 DaveA · Apr 19, 2011 at 08:51 PM 0
Share

Right it's not too general, so I could write my own. I was thinking maybe a SAX parser might be targeted to this type of thing, but this data is not in need of any special love like that. Thanks.

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

No one has followed this question yet.

Related Questions

Is pulling and parsing XML data from 3rd party API call possible? 1 Answer

WWW is not ready downloading yet? 1 Answer

Parsing and displaying KML 0 Answers

Any way to speed up WWW requests? 2 Answers

Loading xml data from www.text 2 Answers


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