mobilekid
mobilekid

Reputation: 1629

libxml2 xmlChar* cast to char*

How would you convert / cast an xmlChar* to char* from the libxml2 library? Thanks.

Upvotes: 16

Views: 20577

Answers (2)

darelf
darelf

Reputation: 4659

If you take a look at the examples, for instance io2.c, you'll notice that they just blithely cast it to a char *:

printf("%s", (char *) xmlbuff);

Upvotes: 13

Matthew Flaschen
Matthew Flaschen

Reputation: 284836

Looks like it's just unsigned char. So it should be safe to cast as long as you're not doing arithmetic on it.

But, you probably don't need to as that page has the key string functionality implemented in terms of the type.

Upvotes: 6

Related Questions