Namespaces apply to the current tag, and all decendants, you the tag that
declares the namespace can be from that namespace:

<test:myTag xmlns:test="....">
<test:myOtherTag />
</test:myTag>

XML is stringent about single root elements, and since CF's implementation
adheres, it won't let you have multiple ones.  However, if you need to add
it dynamically, it's simple.  Check if there is an xml declaration, check if
there's a DOCTYPE declaration, and the first ">" that's not part of either
of those is the end of the root element.  Just replace it with the namespace
you need, plus the bracket.

Cheers,
barneyb

> -----Original Message-----
> From: Tyler Silcox [mailto:[EMAIL PROTECTED]
> Sent: Monday, May 10, 2004 11:04 AM
> To: CF-Talk
> Subject: RE: Namespaces in XMLParse() file...
>
> As usual, I figured out part of this right after I hit sent
> on my message:
>  
> <tests xmlns:test="http://www.test.com">
>      <one name="something" value="else" />
>      <test:uno test="oh no" />
>      <two name="something" value="else" />
> </tests>
>  
> If I add the namespace declaration to the root element, it
> won't throw an
> error.  
>  
> I know it is not quite proper, but is there a way to get
> around declaring
> the namespace in the root element? I'd like to declare before the root
> element if I could....is this possible or is CF pretty
> stringent about it's
> "only one root element" rule?
>  
> Tyler S.
>
>   _____  
>
> From: Tyler Silcox [mailto:[EMAIL PROTECTED]
> Sent: Monday, May 10, 2004 1:58 PM
> To: CF-Talk
> Subject: Namespaces in XMLParse() file...
>
>
> Are there any tricks to get CFMX to parse a XML file with
> referenced or
> unreferenced namespaces in them?
>
>
> I have a XML file that I can read just fine, but when I try to run a
> XMLParse() on the variable, it throws me a NAMESPACE_ERR
> error. And if I
> take out the tag with the namespace in it, it works just fine:
>
>
> <tests>
> <one name="something" value="else" />
> <test:uno test="oh no" />                                <!--
> this throws an
> error -->
> <two name="something" value="else" />
> </tests>
>
>
> Tyler S.
>   _____  
>
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to