Re: [xml] namespace problem





On Mon, Jan 4, 2010 at 12:06 AM, Andreas Wagner <andreaswagner7 gmail com> wrote:


2010/1/3 Emmanuel Rodriguez <emmanuel rodriguez gmail com>


On Sun, Jan 3, 2010 at 9:16 PM, Andreas Wagner <andreaswagner7 gmail com> wrote:
Hi Emmanuel,

thx for ur answer, but it is still the same problem. I must be in the right node (correct line), but i do not get the attributes :-(
Sorry I read your first mail too fast and focused only on the namespace and not on the node!

You need to use the URI for nodes that use a namespace. In your case only some elements use namespaces but the attributes don't. Since the attributes have no namespace you will need to use another function. Try to use xmlGetNoNsProp() or xmlGetProp().

Â
--
Emmanuel Rodriguez

No problem, but i tried the other functions and i just get NULL. Maybe its a problem that i work with eclipse under Windows and a static lib. I get one warning when i compile my program (but that should just be the xmlfree() function). Tomorrow i will try VC 2008.
I've attached an simple example that shows how to get attributes from some nodes.
Â

So i have another question. what shall happen when the current node (cur) is a node in this namespace and i say: cout << cur->nsDef->prefix << endl; (i expect that the output is the prefix?? or??) My application crashes. And i do not know if it is my mistake or a mistake of the enviroment.
I think that you want to use cur->ns to get the current namespace. It could be possible that a node has namespace declarations but that it uses none of them (it's children might use them).

It's also not a good practice to rely on namespace prefixes. Renaming the namespace prefixes shouldn't affect an XML parser nor an application as long as the namespaces refer to the same URI. An XML parser cares that the nodes namespaces refer to the same URI for an exact match, the value of the prefix (if there was one) is of no importance to the parser.

--
Emmanuel Rodriguez

Attachment: ns.c
Description: Text Data



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