Re: [xml] Fwd: Determing element namespace prefix

Akarsha Kumar wrote:

I had sent the message forwarded below to the list a few days ago. I am
looking for a way to obtain namespace prefixes in element names.

Any help in this matter would be greatly appreciated.


---------- Forwarded message ----------
From: Akarsha Kumar <akikumar gmail com>
Date: Jan 2, 2007 3:41 PM
Subject: Determing element namespace prefix
To: xml gnome org


Is there a straightforward way to determine if an element has a namespace
prefix? For the following element:

<myns:Elem> some data </myns:Elem>

I would like to obtain the string "myns:Elem". simply returns
"Elem" and I can't find an obvious way to get to the "myns" part as well.


Hi Aki,

I think what you want is xmlNode.ns->prefix.

I access namespaces on attributes, and I get to them as>ns->prefix.

My code checks that both the ns pointer and the ns->prefix pointer are non-NULL before comparing the prefix string. I don't remember if that's just paranoia or if I discovered cases where NS could be non-NULL while ns->prefix was NULL.

- Rush

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]