Hi Peter,

Peter wrote:
 >I've found that removeNamespace() doesn't work if there are existing 
attributes or elements using that namespace

I suppose that every element in the file uses the namespace, since it is 
the "default" namespace, ie:
xmlns="http://path.to.com/someplace";

Here's how I'm removing the namespace, rather,  trying to:
where myXML:XML is a parsed XML document

            for (var i:uint = 0; i < 
myXML.namespaceDeclarations().length; i++) {
                var ns:Namespace = myXML.namespaceDeclarations()[i];
                var prefix:String = ns.prefix;
                myXML.removeNamespace(ns);
          }

As an example, I have two namespaces at the root of my document 
declared.  One is a custom namespace with a prefix (and no elements use 
it) - this one is removed.  The other is the default namespace, without 
a prefix, this one sticks around.

-Steve



Peter Farland wrote:
> I've found that removeNamespace() doesn't work if there are existing
> attributes or elements using that namespace... have you tried first
> deleting any of these and then tried to remove the namespace? Also, when
> you're calling removeNamespace, how are you constructing the Namespace
> instance to pass in to the function?
>
> ________________________________
>
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of shagenlo
> Sent: Monday, December 04, 2006 9:12 PM
> To: [email protected]
> Subject: [flexcoders] removeNamespace() and the default namespace in XML
>
>
>
> Hello,
>
> I realize this topic was covered a bit in a thread titled "Namespace
> hell", however I didn't see a resolution to a lingering question. Is
> there any way to use the removeNamespace() method of the XML class to
> remove the default namespace (the namespace without a prefix)?
>
> I would like to do this, because i have an object heirarchy which
> represents an unstructured XML document (not a recordset). In
> serializing the object structure, the new XML can get littered with
> namespace declares, it would be easier to simply remove the original
> default namespace and be done with it. Name collisions are not a
> concern for me, but the fact that removeNamespace() doesn't work with
> the default namespace is. Is there an answer other than RegEx on the
> xml string?
>
> Cheers,
> Steve
>
>
>
>  
>
>   

Reply via email to