Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6822213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:38:11+00:00 2026-05-26T21:38:11+00:00

I’ve been trying to write to a file the results of an xmlhttp GET

  • 0

I’ve been trying to write to a file the results of an xmlhttp GET request. I have tried the code below:

set the_file to "/Users/xxxx/Documents/outputvals.txt" as file specification

set the_data to costItems

try
    open for access the_file with write permission
set eof of the_file to 0
write (the_data) to the_file starting at eof as list
close access the_file
end try

However it doesn’t seem to write anything to the file. Ideally I want to write the xml ‘costItems’ to the end of a text file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:38:11+00:00Added an answer on May 26, 2026 at 9:38 pm

    Generally, if you want to do anything with a file or folder, it must be a complete alias reference. Just change as file specification to as POSIX file as alias and that part will work!

    Also, remove the as list and delete the line set eof of the_file to 0. Assuming the file already contains information, you’re basically telling the script that the end of the file is the beginning of the file.

    I hope this helps!

    EDIT: I don’t know why your code isn’t working properly (it does for me). Well, I guess you could try the following (kind of hacky, though, but oh well 😛 )

    tell application "Finder"
        try
            set the_file to "/Users/xxxx/Documents/outputvals.txt" as POSIX file as alias
        on error --file doesn't exist yet, so create it
            set the_file to (make new document file at ("/Users/xxxx/Documents/" as POSIX file as alias) with properties {name:"outputvals", text:""}) 
            --Normally, when you're creating documents in this fashion, you would put the text you want in the document after the 'text' property, but for your sake I will use the alternative :)
        end try
    end tell
    set the_data to costItems
    try
        open for access the_file with write permission
        write the_data to file the_file starting at eof
        close access the_file
    on error --you never know when errors will crop up (when it comes to reading and writing files); better to be safe than sorry
        try
            close access the_file
        end try
    end try
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a reasonable size flat file database of text documents mostly saved in
I have a view passing on information from a database: def serve_article(request, id): served_article
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.