Comments (7)
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.
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.
Thank you. Already use it. :)
from cheerio.
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.
@SlavaB xmlMode
needs to be true
.
from cheerio.
It doesn't make any difference, true or false.. The result is the same.
from cheerio.
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)
- How to "replaceWith" on plain text, which is not a DOM Elements? HOT 5
- Unsafe legacy renegotiation disabled
- text() method merges text parts HOT 3
- Bug: Crawler reached the maxRequestsPerCrawl limit of 1 requests and will shut down soon HOT 1
- Bug: XML tags with mixed case, when using lowerCaseTags: true, selectors will be lowercased before comparing with the xml tag name
- exporting function from battiers
- Error with nextjs 14 HOT 1
- Cherrio is unable to retrieve content with property of og in the meta tag HOT 3
- If the page is SPA (such as Vue), can't I use Cheerio to retrieve the content of the website that has been fully loaded HOT 1
- whitespace normalization removes NBSP chars in xmlMode HOT 1
- Can´t select elements based on their position in the document HOT 8
- Live Editor Result Panel Blank
- how to add defer to script tag HOT 1
- Weird behaviour with HTML entities within XML content
- Behaving exceptionally in template syntax containing curly braces HOT 1
- error TS2724: '"/app/node_modules/cheerio/lib/esm/index"' has no exported member named 'Text'
- Using XML format for obfuscation
- Some attributes values get ="" appended to values
- Calling .text() is doubling the value with a space in the middle HOT 1
- Chaining `replaceWith` method takes only the first one HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cheerio.