Re: Expat and JavaScript

Karl Waclawek <[email protected]>
Newsgroups gmane.text.xml.expat.general
Message-ID <[email protected]>
Franky Braem wrote:
> I'm porting expat to JavaScript (using SpiderMonkey, see my wxJS 
> project). The application is in Unicode.
> I have the following problem:
>
> When I pass a normal JavaScript string (SpiderMonkey uses UTF-16) to a 
> 'print' method I don't have to do any conversions to write the data to 
> stdout.
> When I use a string generated by expat (it is build in UNICODE and 
> creates data in UTF-16) I have to do a conversion before I can send the 
> string to the 'print' method.
> When I look at the expat string in debug mode, I see all weird Chinese 
> characters. When I debug the normal JavaScript string, I see normal text.
> Is there a conversion needed between SpiderMonkey and Expat?
>
> Maybe this JavaScript code makes some things clearer:
>
> p.parse('<tag1 attr="1" attr2="2"><child1>child</child1></tag1>', true);
> if ( p.currentElement.name == "tag1")
> {
>  wxJS.print("Ok");
> }
> else
> {
>  wxJS.print("Not ok");
> }
> wxJS.print(p.currentElement.name);
>
> The comparison always fails (all though the parsing in expat went fine)
>
>   

How does p.currentElement.name get its value from Expat?

Karl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.