Jump to content
  • Advertisement
Sign in to follow this  
lincsimp

xerces problem

This topic is 4834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi I've just started using xerces with c++. How can I output the xmlch? const XMLCh* value=root->getNodeValue(); cout<<"["<<value<<"]"<<endl; This just ouptuts [00000000] How can i output the node value? cheeers

Share this post


Link to post
Share on other sites
Advertisement
XMLCh is probably a 16-bit char (it is with my setup). I don't know if you can compile it to use something else like UTF-8 but if you could that would be awsome. Anyway to answer your question I have a class



class w2n
{
public:
w2n( const wstring::value_type *ptr )
{
for ( ; *ptr; ++ptr )
{
_str += *ptr & 0xff;
}
}

operator string() const
{
return _str;
}

operator const char *() const
{
return _str.c_str();
}

private:
string _str;
};





and then I call the constructor:


w2n( label );





Lots of ways of getting the same result of course... also this is probably not the fastest or even the correct way of moving from 16-bit to 8-bit characters.

Share this post


Link to post
Share on other sites
Thanks!
I have this:


const XMLCh* value=root->getNodeValue();
cout<<w2n(value)<<endl;

I got an error:

Unhandled exception at 0x00418755 in LanguageConverter.exe: 0xC0000005: Access violation reading location 0x00000000.

at this line:

for ( ; *ptr; ++ptr )

whats wrong?

Share this post


Link to post
Share on other sites
Quote:
Original post by lincsimp
Thanks!
I have this:


const XMLCh* value=root->getNodeValue();
cout<<w2n(value)<<endl;

I got an error:

Unhandled exception at 0x00418755 in LanguageConverter.exe: 0xC0000005: Access violation reading location 0x00000000.

at this line:

for ( ; *ptr; ++ptr )

whats wrong?


maybe getNodeValue() is returning null? In fact I would guess that's why its outputing 00000000 because the pointer is null... Since cout doesn't have a method for short*, it just uses the default for void* and prints the address.

Share this post


Link to post
Share on other sites
Thanks, I don't see why it would return null, here's the code:


XMLCh tempStr[100];

XMLString::transcode("Range", tempStr, 99);
DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(tempStr);

XMLString::transcode("root", tempStr, 99);
DOMDocument* doc = impl->createDocument(0, tempStr, 0);
DOMElement* root = doc->getDocumentElement();

XMLString::transcode("FirstElement", tempStr, 99);
DOMElement* e1 = doc->createElement(tempStr);
root->appendChild(e1);

XMLString::transcode("SecondElement", tempStr, 99);
DOMElement* e2 = doc->createElement(tempStr);
root->appendChild(e2);

XMLString::transcode("aTextNode", tempStr, 99);
DOMText* textNode = doc->createTextNode(tempStr);
e1->appendChild(textNode);

// optionally, call release() to release the resource associated with the range after done
DOMRange* range = doc->createRange();
range->release();

// removedElement is an orphaned node, optionally call release() to release associated resource
DOMNode* removedElement = root->removeChild(e2);
removedElement->release();

// no need to release this returned object which is owned by implementation
XMLString::transcode("*", tempStr, 99);
DOMNodeList* nodeList = doc->getElementsByTagName(tempStr);
//DOMNode* test = (DOMNode)root;

const XMLCh* value=root->getNodeValue();
cout<<w2n(value)<<endl;



can anyone give some guidance????

cheers

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!