Code Monkey home page Code Monkey logo

Comments (4)

astro avatar astro commented on July 18, 2024

Not sure I understand. The 2nd example has 3 children: a text node, the <y/> child, and another text node. Why should this be 1?

Squashing whitespace around elements may not be appropriate for all use cases. In XHTML, <b>Hello</b><i>World</i> would be rendered differently from <b>Hello</b> <i>World</i>.

from ltx.

flosse avatar flosse commented on July 18, 2024

Ok, You're right!
I thought that whitespace/text between two tags (e.g. <a>foo<b/> </a>) is not valid.
So in case my client accidentally added whitespaces (<value> <int>4</int></value>) I'll have problems if I try to access the child by just using it's order

valueElement.children[0] // returns ' ' instead of 4

As long as I know the tag name I can use getChildText("int") otherwise it might be great if there were a method like el.trim() that removes all whitespaces that are not within a tag?

from ltx.

astro avatar astro commented on July 18, 2024

Generally I'd suggest using valueElement.getChild('int'). That way you would assert that the first child is <int/> indeed, not anything else.

A patch for a handy trim() will be accepted!

from ltx.

astro avatar astro commented on July 18, 2024

BTW. As an european open source hacker, do you have any plans regarding FOSDEM 2012? I won't be there, but @dodo is planning to go!

from ltx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.