Giter Club home page Giter Club logo

Comments (7)

siddMahen avatar siddMahen commented on August 28, 2024 3

You can now do:

var cheerio = require("cheerio"),
    html = '<link>foo</link>',
    $ = cheerio.load(html, { xmlMode: true });

console.log($("link").text())

Which will return:

foo

from cheerio.

siddMahen avatar siddMahen commented on August 28, 2024

Thanks for bringing this up. I think it's being caused by a bug in htmlparser2. I've submitted an issue here: FB55/node-htmlparser#16

from cheerio.

SlavaB avatar SlavaB commented on August 28, 2024

Thank you. Already use it. :)

from cheerio.

SlavaB avatar SlavaB commented on August 28, 2024

But working with tag remains incorrect.

var cheerio = require("cheerio"),
$ = cheerio.load('<root></root>', { xmlMode: false });
$('root').append($('<link></link>').text('foo'));
$('root').append($('<someTag></someTag>').text('some text'));
console.log($.html());

The code above returns the following:

<root><link/>foo<someTag>some text</someTag></root>
instead
<root><link>foo</link><someTag>some text</someTag></root>

from cheerio.

fb55 avatar fb55 commented on August 28, 2024

@SlavaB xmlMode needs to be true.

from cheerio.

SlavaB avatar SlavaB commented on August 28, 2024

It doesn't make any difference, true or false.. The result is the same.

from cheerio.

vitorefigenio avatar vitorefigenio commented on August 28, 2024

Hello, i need read a XML like this:

<Main>
<Child ID="1" Type="ABC" Dealer="" Name="Vitor" Street="ABC st" Number="2350" N="Local" City="São Paulo" State="SP" PostalCode="01111-100" Parking="Não" Lat="-46.6624320" Long="-23.5578566"> 
<People="90" Saturday="09h" Holiday="Close"/>
</Child>
</Main>

But I can't. Somebody Help me? I want structured this XML code to a Data Base:
Name: 'Vitor'
Street: 'ABC st'
Number: '2350'

from cheerio.

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.