1

I just insalled the Multi-Device Hybrid Apps (Preview) for VS 2013 and created an new project, which works fine. Now I want to open some xml files I added to the soltution inside the app and I'm wondering how to do this.

Is there an easy way to open an parse local xml files?

Priyank
  • 1,568
  • 10
  • 15
Philipp
  • 15,377
  • 4
  • 35
  • 52
  • 1
    Your questions seems unclear - if you only want to view the contents of the XML, open it from the project directory listing in the solution explorer on the right. If your question is instead around accessing XML files in your project and parsing them through code, please modify the question above to add more details on your use case. – Priyank May 20 '14 at 19:18
  • I mean the second.. opening files in the solution shouldn't relly be a problem for anyone – Philipp May 20 '14 at 21:07
  • possible duplicate of [How to Deserialize XML document](http://stackoverflow.com/questions/364253/how-to-deserialize-xml-document) – mason Sep 04 '14 at 19:17

1 Answers1

2

For read an xml embedded in app package at runtime you can use for example jquery whitout problem.

Yourxml.xml:

<?xml version="1.0" encoding="utf-8" ?>
<BookList>
  <Book>
     <Title>title one</Title>
     <Publisher>Publisher one</Publisher>
  </Book>
  <Book>
      <Title>Title two</Title>
      <Publisher>Publisher two</Publisher>
  </Book>
</BookList>

Reading:

$.ajax({
    type: "GET",
    url: "yourxml.xml",
    dataType: "xml",
    success: function(xml) {
        $(xml).find('Book').each(function(){
            var sTitle = $(this).find('Title').text();
            var sPublisher = $(this).find('Publisher').text();
        });
    }
});
Frix33
  • 1,231
  • 10
  • 27
  • While that link might answer the question its best to at least summarize the contents here (in case the link breaks). – Jack Sep 04 '14 at 19:29