locked
Help using XML as a local database

    Question

  • Hey all! I'm a bit new to JS development, I've dabbled in VB and C++ a bit over the years, and lots of HTML/CSS, which is why I decided to go for JS development. However, I'm struggling a bit, I was hoping some expert could take a glance and tell me what I'm doing wrong! Basically, since there is a lack of a SQL database (as far as I can see) I've decided to use a simple XML database for storing values that are used for my application. So I looked at the sample MS has here on MSDN, and created the following test code:

     

            var data = new Windows.Data.Xml.Dom.XmlDocument;
            data.loadXml("database.xml");
            var childname = data.selectNodes("/app/listitems/GM-010101");
            var item1 = childname.firstChild.nodeValue

    .

    <?xml version="1.0" encoding="utf-8" ?> 
    
    <app>
      <listitems>
        <GM-010101>
          <title>Item 1</title>
          <desc>1This is a description of the item in this list</desc>
          <link>C:\Windows\explorer.exe</link>
          <img>images/smalllogo.png</img>
        </GM-010101>
      </listitems>
    </app> 


    I then insert "item1" onto the page. However, I'm getting an error: "Invalid at the top level of the document." I've tried tons of different combinations of info available on the Windows.Data.Xml.Dom.XmlDocument MSDN resource site, but I don't think I'm familiar enough with JS syntax yet, and its just going right over me! So has anyone gotten anything like this working? Or is there a better option for storing dynamically changing variables that will stay when the app is closed??

    PS: Microsoft, please get this page updated! It'll solve all of my problems! :)
    http://msdn.microsoft.com/en-us/library/windows/apps/br229561(v=VS.85).aspx  

     


    • Edited by coreyw2010 Sunday, December 25, 2011 11:54 PM
    Sunday, December 25, 2011 11:46 PM

Answers