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

  • Home
  • SEARCH
  • 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 8718497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:33:56+00:00 2026-06-13T06:33:56+00:00

I have been looking to this example but could not make it work. I

  • 0

I have been looking to this example but could not make it work.

I need to generate a local XML file when user clicks a button.

I need to create an xml like this one

<array>
        <dict>
            <key>files</key>
            <array>
                <dict>
                    <key>date</key>
                    <string>2012/09/09</string>
                    <key>name</key>
                    <string>acatBriefing.pdf</string>
                    <key>description</key>
                    <string>ACAT Briefing</string>
                </dict>
            </array>
            <key>subject</key>
            <string>FAE approved ACAT Designations</string>
            <key>presenter</key>
            <string>Rebecca T. King</string>
            <key>time</key>
            <string>2:00 - 2:05 PM</string>
        </dict>
</array>

I tried something like:

function generateXML(){
    // Simple helper function creates a new element from a name, so you don't have to add the brackets etc.
$.createElement = function(name)
{
    return $('<'+name+' />');
};

// JQ plugin appends a new element created from 'name' to each matched element.
$.fn.appendNewElement = function(name)
{
    this.each(function(i)
    {
        $(this).append('<'+name+' />');
    });
    return this;
}

/* xml root element - because html() does not include the root element and we want to
 * include <report /> in the output. There may be a better way to do this.
 */
var $root = $('<XMLDocument />');

$root.append
(
    // one method of adding a basic structure
 $('<plist />').append
    (
    $('<dict />').append
    (
        $('<key />').text('subject')
        $('<string />').text('September 21')
        $('<key />').text('date')
        $('<string />').text('FOB10 Room')
        $('<key />').text('time')
        $('<string />').text('2.00 pm - 5.00 pm')
        $('<key />').text('briefings')

        $('<array />').append
            (
                $('<dict />').append
                    (
                       $('<key />').text('files')
                       $('<array />').append
                            (
                            $('<dict />').append
                                (
                                  $('<key />').text('date')
                                 $('<string />').text('09/09/2012')
                                    $('<key />').text('name')
                                 $('<string />').text('acatBriefing.pdf')
                                 $('<key />').text('description')
                                   $('<string />').text('ACAT Briefing')
         )
        )
             $('<key />').text('subject')
             $('<string />').text('FAE approved ACAT Designations')
                $('<key />').text('presenter')
             $('<string />').text('Rebecca T. King')
             $('<key />').text('time')
               $('<string />').text('2.00 - 2.05 PM')

       )
      )
    )
   )
);


alert($root.html());
}

I could not do it, how can I create a local XML file with jQuery?

  • 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-06-13T06:33:57+00:00Added an answer on June 13, 2026 at 6:33 am

    your function was correct, u just missed putting some commas;

    edited code:

        function generateXML(){
        // Simple helper function creates a new element from a name, so you don't have to add the brackets etc.
        $.createElement = function(name)
        {
            return $('<'+name+' />');
        };
    
        // JQ plugin appends a new element created from 'name' to each matched element.
        $.fn.appendNewElement = function(name)
        {
            this.each(function(i)
            {
                $(this).append('<'+name+' />');
            });
            return this;
        }
    
        /* xml root element - because html() does not include the root element and we want to
            * include <report /> in the output. There may be a better way to do this.
            */
        var $root = $('<XMLDocument />');
    
        $root.append
        (
        // one method of adding a basic structure
        $('<plist />').append(
        $('<dict />').append(
        $('<key />').text('subject'),
        $('<string />').text('September 21'),
        $('<key />').text('date'),
        $('<string />').text('FOB10 Room'),
        $('<key />').text('time'),
        $('<string />').text('2.00 pm - 5.00 pm'),
        $('<key />').text('briefings'),
    
        $('<array />').append
        (
        $('<dict />').append
        (
        $('<key />').text('files'),
        $('<array />').append
        (
        $('<dict />').append
        (
        $('<key />').text('date'),
        $('<string />').text('09/09/2012'),
        $('<key />').text('name'),
        $('<string />').text('acatBriefing.pdf'),
        $('<key />').text('description'),
        $('<string />').text('ACAT Briefing')
    )
    ),
        $('<key />').text('subject'),
        $('<string />').text('FAE approved ACAT Designations'),
        $('<key />').text('presenter'),
        $('<string />').text('Rebecca T. King'),
        $('<key />').text('time'),
        $('<string />').text('2.00 - 2.05 PM')
    
    )
    )
    )
    )
    );
    
    
        alert($root.html());
    }
    generateXML();
    

    just note my generateXML() at the end there in case u suddenly get alerts from nowhere

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking everywhere but could not find a tutorial for this. I
I have been looking for an answer to this and could not find it
I have been googling around this issue, but could not find clear and definitive
I have been looking for an answer to this on Stack Overflow, but I
I have been looking around the web for this but cannot really find a
I have been looking over the internet for a while about this, but it
I've been looking around for ways to do this. How could I make it
I have been looking at this for to long so I am tossing it
I have been looking over this code for the past hour, I cant see
I have been looking all over for this. I have two seperate prpt files

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.