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 8265333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:45:48+00:00 2026-06-08T04:45:48+00:00

Given the following sample XML (here I am showing hard-coded, but normally I load

  • 0

Given the following sample XML (here I am showing hard-coded, but normally I load from an external file):

var myXML:XML = new XML('
    <xmlout xmlns:ns1="http://some.namespace.com/ns1" xmlns:ns2="http://some.namespace.com/ns2" xmlns:ns3="http://some.namespace.com/ns3">
        <data>
            <item>
                <ns1:id>some_id</ns1:id>
            </item>
        </data>
    </xmlout>');

I am storing the namespaces as namespace objects in an object, like:

var xmlNamespaces:Object = {};

for (var i:uint = 0; i < myXML.namespaceDeclarations().length; i++) {
    var ns:Namespace = myXML.namespaceDeclarations()[i]; 
    xmlNamespaces[ns.prefix] = new Namespace(ns.prefix, ns.uri);
}

I am trying to do something like:

trace(myXML.data.item.xmlNamespaces["ns1"]::id.value);

Any idea if this is possible? I have not had any success. Thanks!

Edit:
I should note that I can do this, with no problem, using:

default xml namespace = xmlNamespaces.ns1;
var id:String = myXML.data.item.id;

I am specifically trying to figure out how to eliminate having to set the default namespace every time…

  • 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-08T04:45:50+00:00Added an answer on June 8, 2026 at 4:45 am

    Sorry this has been taking me so long to get back to you as I am sure you probably needed it yesterday.
    I was on the road for 8 hours today.
    Writing inline XML requires the use of a single root node to define the body of the XML document.
    Your first issue is you wrapped everything with a single quote. Take it out the parameter is not a string.
    Your other issue as stated above you need to wrap it with a root tag.
    This code compiles fine in flash cs4 let me know if you still can’t get that to work.
    Notice in the code below I never reference the root node.

    var myXML:XML = new XML(
        <root>
            <xmlout xmlns:ns1="http://some.namespace.com/ns1" xmlns:ns2="http://some.namespace.com/ns2" xmlns:ns3="http://some.namespace.com/ns3">
                <data>
                    <item>
                        <ns1:id>some_id</ns1:id>
                    </item>
                </data>
            </xmlout>
        </root>);
    
    
    var xmlNamespaces:Object = {};
    
    for (var i:uint = 0; i < myXML.xmlout.namespaceDeclarations().length; i++) {
        var ns:Namespace = myXML.xmlout.namespaceDeclarations()[i]; 
        trace(ns.prefix + ' ' + ns.uri)
        xmlNamespaces[ns.prefix] = new Namespace(ns.prefix, ns.uri);
    }
    // output is 
    // ns1 http://some.namespace.com/ns1
    // ns2 http://some.namespace.com/ns2
    // ns3 http://some.namespace.com/ns3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following XML file: <?xml version=1.0 encoding=UTF-8?> <process name=TestSVG2 xmlns=http://www.example.org targetNamespace=http://www.example.org xmlns:xsd=http://www.w3.org/2001/XMLSchema> <sequence>
I have written the following piece of code that reads through a given xml-file
Following is sample XML File - <?xml version=1.0 encoding=UTF-8?> <Catalog> <Book> <AName>Steven Holzner</AName> <BName>Using
Given the following code sample: uint8_t i, in, ni; i = in = 2;
A little stuck here. I have a simple question I guess. Given the following
Given following array: var arr = [undefined, undefined, 2, 5, undefined, undefined]; I'd like
Given following Statment: String query = "Select * from T_spareParts where SparePartPK IN (?
I've used the following code to do an XSLT in php: # LOAD XML
im tryin to populate check boxes and set their values from a xml file
I'm looking for code which can do the following. Given a snippet of XML,

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.