g6ling / react-native-html-parser Goto Github PK
View Code? Open in Web Editor NEWcan use html parser in react-native/titanium and anywhere
License: GNU Lesser General Public License v2.1
can use html parser in react-native/titanium and anywhere
License: GNU Lesser General Public License v2.1
It looks like both repos have similar codebases?
.then((res) => { const parser = new DOMParser.DOMParser(); const parsed = parser.parseFromString(res, 'text/html'); alert(parsed);
the error pops up and then the alert with the right parsed html code comes. but I cant work with it because of this error, please help me.
"dependencies": { "@react-native-community/async-storage": "^1.6.2", "lodash": "^4.17.11", "react": "16.8.3", "react-native": "0.59.5", "react-native-elements": "^1.1.0", "react-native-gesture-handler": "^1.4.1", "react-native-html-parser": "^0.0.5", "react-native-i18n": "^2.0.15", "react-native-linear-gradient": "^2.5.4", "react-native-material-dropdown": "^0.11.1", "react-native-modal": "^10.0.0", "react-native-progress": "^3.6.0", "react-native-restart": "^0.0.10", "react-native-swipe-gestures": "^1.0.3", "react-native-vector-icons": "^6.4.2", "react-native-webview": "^7.4.2", "react-navigation": "^3.9.1" }, "devDependencies": { "@babel/core": "^7.4.4", "@babel/runtime": "^7.4.4", "babel-jest": "^24.7.1", "jest": "^24.7.1", "metro-react-native-babel-preset": "^0.53.1", "react-test-renderer": "16.8.3" }
console.log(querySelecotr('.div.aa class#a a'))
did you mean console.log(querySelector('.div.aa class#a a'))
?
As the title states when trying to get a documents favicon instead of getting a few items I get a lot of unrelated things, would you mind checking it?
// get the string html from https://www.youtube.com/watch?v=wuClZjOdT30
// expect to retrieve img/favicon_32-vflOogEID.png
doc.querySelect('link[rel=icon]') // returns like a 100 items
I want to use addEventListener in react-native. Is there any plan to this in current module?
Is there any guide available so that I can add that by my self?
The readme shows:
console.log(findSelector('div.aa#in[ii="a"]'))
but I cannot find findSelector
anywhere. I was unable to get querySelect
to find based on any attribute, I resorted to getElementsByAttribute
, but I would really prefer to use a css selector.
Hi
I tried to use this package in my project but suddenly 3 times app has been crashed
expo sdk 46
react native 0.69.3
The QuerySelector on attributes works only with values that match a-z or A-Z.
The following attributes could not be used for querying:
var DOMParser = require('react-native-html-parser').DOMParser;
var doc = new DOMParser().parseFromString('<input name="test_token"><input name="test-token"><input name="test123">');
doc.querySelect('input[name="test_token"]'); // gets all input fields
doc.querySelect('input[name="test-token"]'); // gets all input fields
doc.querySelect('input[name="test123"]'); // gets all input fields
The React Native ExceptionsManager is showing the following exception when trying to parse an invalid HTML document which contains not properly closed tags.
[xmldom fatalError] end tag name: tr is not match the current start tagName:table
@#[line:370,col:76]
How can I capture the exception to prevent the application from crashing?
For example, I query elements with class .paddle-event, i get nothing because internally the lib only searches for elements with class .paddle.
Same for h3 (and the like) elements. Internally it only searches for 'h' tags which don't exist!
I'm getting the error "[xmldom fatalError] end tag name: p is not match the current start tagName:undefined" while trying to parse an html string
import DOMParser from 'react-native-html-parser';
const parser = new DOMParser.DOMParser();
render(){
const parsed = parser.parseFromString(item.excerpt, 'text/html');
return <Text style={styles.ListItem_brief}>{parsed}...</Text>
}
the string being parsed is:
"
Disney Theatrical Productions and Frozen have partnered with The Actors Fund to celebrate International Women’s Day with two special events: “Women’s Day on Broadway: …
<a href="https://thewaltdisneycompany.com/disneys-frozen-partners-actors-fund-celebrate-international-womens-day/\" class="button button-more">Read More</p>\n"
I apologise for the bad pic, the phone doesn't allow screenshots
I'm using Type Script, and there's already the types for the official DOMParser types.
Here are the types for QuerySelector
function:
And this is the official documentation https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector
The problem is that for some reason in this package we have querySelect
instead of querySelector
, and this fact breaks type checking:
Any reason for having a different name? Can this be fixed?
This library is really greet, specially when it could handle the missing html tags.
Now there is still to much work to be done.
1- Methods name is wrong eg querySelect
.
2- This need to work with typescript, eg need to implement types.
3- querySelect
dose not really work like it should be, take for example this selector ".test> p:first-child"
this will not return the correct data at all.
I made this library work together with node-html-parser
where is this library will parse the html and correct all missing html tags and then I use node-html-parser
to reparse the html return from this library and work there after with the html.
I really want to skip this as it takes more time then it should take.
It would be great to have a look at node-html-parser
and use their type/selector operation but use this library as html parser.
Is there is plan to do this ?
Hey,
How do I query more than one element?
I would like to query all the images
Thanks,
let doc = new DomParser().parseFromString(response,'text/html') console.log(doc.getElementsByTagName('meta'))
'[xmldom error] parse error: TypeError: source.indexOf is not a function. (In 'source.indexOf('<',start)', 'source.indexOf' is undefined)', '\n@#[line:0,col:undefined]'
As the title says, I am having problems with named HTML entities.
Steps to reproduce:
import DOMParser from 'react-native-html-parser';
const html = `<p>Hello world <b>world</b> <i>foo</i> bar hahhö</p>`;
const parser = new DOMParser.DOMParser();
const parsed = parser.parseFromString(html, 'text/html');
Expected behaviour:
HTML string gets parsed
Actual behaviour:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.