xml read/write error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • jackdaniels
    No longer a forum member
    • Mar 2007
    • 533

    xml read/write error

    Global Functions :
    Code:
    	
    function SetMenu()
    	-- Create a table containing all menu information
    	tblMenu = {};
    	tblMenu[1] ={};
    	tblMenu[1].Text = "&Favorites";
    	tblMenu[1].ID = 400;
    	tblMenu[1].Checked = false;
    	tblMenu[1].Enabled = true;
    	tblMenu[1].SubMenu = {};
    	XML.Load("AutoPlay\\Docs\\BookMarks.xml");
    	error = Application.GetLastError();
    	if (error == XML.OK) then
    		nCount = XML.Count("bookmarks", "site");
    		if nCount ~= 0 then
    			mI=1
    			for i=1, nCount do
    				tblMenu[1].SubMenu[mI] = {};
    				tblMenu[1].SubMenu[mI].Text = XML.GetValue("bookmarks/site:"..i.."/name");
    				tblMenu[1].SubMenu[mI].ID = 3000+i;
    				tblMenu[1].SubMenu[mI].Checked = false;
    				tblMenu[1].SubMenu[mI].Enabled = true;
    				mI=mI+1
    			end	
    		end
    	else    
    	    Dialog.Message("Error", _tblErrorMessages[error]);
    	end
    
    	Application.SetMenu(tblMenu);
    end
    On Preload:
    Code:
    SetMenu()
    On Menu:
    Code:
    if e_ID > 3000 then
    	urlID=e_ID-3000
    	tbURL = XML.GetValue("bookmarks/site:"..urlID.."/url");
    	Web.LoadURL(actweb, tbURL);
    end
    Save To Favorites On Button Click:
    Code:
    Stitle = Dialog.Input("Site Name", "Please Write Site Name:", "", MB_ICONQUESTION);
    if (Stitle ~= "CANCEL") then
    	url = Input.GetText("Input1");
    	XML.Load("AutoPlay\\Docs\\BookMarks.xml");
    	count = XML.Count("bookmarks", "site");
    	XML.InsertXML("bookmarks/site:"..count, "<site>\r\n<name>"..Stitle.."</name>\r\n<url>"..url.."</url>\r\n</site>\r\n", XML.INSERT_AFTER);
    	XML.Save("AutoPlay\\Docs\\BookMarks.xml");
    	SetMenu()
    end
    when i click save button i get this error;
    Last edited by jackdaniels; 03-31-2008, 04:09 AM.
  • jassing
    Indigo Rose Customer
    • Jan 2001
    • 3124

    #2
    Instead of quoting a ton of code, you might want to strip down to the bare minimum and just post the project file as an attachment...

    My 1st suggestion would be to wrap the xml.load() with a if File.DoesExist() to be sure you're looking at a valid file.

    the 2nd suggestion would be to verify that the xml file is properly formatted.

    Comment

    • Samwise
      Forum Member
      • Mar 2007
      • 7

      #3
      A simple problem I came up against with a similar problem was not specifying the xml load directory properly. Try adding _SourceFolder to the start of your directory. i.e.

      XML.Load(_SourceFolder .. "\\AutoPlay\\Docs\\BookMarks.xml");
      Can you give a sample of your xml as well please.

      Comment

      Working...
      X