cgross / grunt-dom-munger

Grunt task to read and manipulate HTML with CSS selectors.
MIT License
93 stars 40 forks source link

Cheerio converts the XML into lowercase after loading. #12

Closed purem23 closed 10 years ago

purem23 commented 10 years ago

When I load XML string into cheerio it converts all nodes (attributes + element node) into lowercase. Everything works fine but post cheerio transformation my XPath query fails because of all lowercase issue. Is there any way we could avoid this behavior of cheerio?

Thanks, M

cgross commented 10 years ago

Hi M,

Are you using the latest version of dom_munger? There was a fix for issue #10 in the latest release that maintained the case for attribute names.

I'm also wondering what case sensitive elements/attributes you're using. HTML is case insensitive and general practice is to keep all elements/attribute names lower case. The root cause in #10 was a few SVG attribute names that are case sensitive.

So even with the latest release, element names will still be lowercased. Can you tell me what elements you have that case matters?

thanks, -Chris

purem23 commented 10 years ago

I downloaded cheerio few days back... Does it not download its dependencies automatically? I know cheerio is primarily meant for HTML but I am using it to parse XML, do some manipulation and pass it on. Its flexible because it does not care about the namespace info attached to XML and just treat it as attributes.

~M

purem23 commented 10 years ago

Sorry, I guess you meant this is it ??

var $ = cheerio.load(srcContents,{lowerCaseAttributeNames:false});

purem23 commented 10 years ago

I checked it and it works fine for attributes(retaining the case) but not for the Element node. Can this also be added as option that can be passed, while loading the XML?

Something like {lowerCaseElementNames: false}

Thanks, M

cgross commented 10 years ago

Are you using this project? Or are you just using Cheerio?

purem23 commented 10 years ago

Just cheerio for now !

cgross commented 10 years ago

Please don't open issues on a project unless you have an issue with that project.

Also, read the documentation for cheerio. It answers your question.