Questions tagged [domparser]

A DOMParser can parse XML or HTML source stored in a string into a DOM Document.

The DOMParser is specifically used in Javascript to parse XML and HTML sources, however other languages may provide DOMParsers as well. In Javascript the DOMParser is specified in DOM Parsing and Serialization.

543 questions
5
votes
2 answers

javascript, how to remove the elements when using DOMparser with text/html

The code var txt = '
fe
fe
fe
' var parser = new DOMParser(); var temp_node = parser.parseFromString(txt, "text/html").documentElement; console.log(temp_node) This code results in the full html…
GWorking
  • 4,011
  • 10
  • 49
  • 90
5
votes
1 answer

org.xml.sax.SAXParseException: Premature end file

I currently have the following XML file. http://www.cse.unsw.edu.au/~cs9321/14s1/assignments/musicDb.xml My XMLParser.java class. package edu.unsw.comp9321.assignment1; import java.io.File; import javax.xml.parsers.DocumentBuilder; import…
user2268507
5
votes
8 answers

How to extract Heading tags in PHP from a string?

From a string that contains a lot of HTML, how can I extract all the text from

etc tags into a new variable? I would like to capture all of the text from these elements and store them in a new variable as comma-delimited values. Is it…

bluedaniel
  • 2,079
  • 5
  • 31
  • 49
5
votes
2 answers

Get the list of values using dom parser in android

I have to develop an android application. Here i have follows following xml format.
user2218667
  • 607
  • 6
  • 25
  • 46
4
votes
1 answer

troubles trying to parse an html string with DOMParser

here's come the snippet : html = ""; html += ""; html += "test"; html += "

test

"; html += ""; parser = new DOMParser(); dom = parser.parseFromString (html,…
vdegenne
  • 12,272
  • 14
  • 80
  • 106
4
votes
3 answers

jsdom how to get an element inside another element inside foreach

i am new to JSDOM parser. I have the following: I am using the…
Mukil Deepthi
  • 6,072
  • 13
  • 71
  • 156
4
votes
2 answers

HTML 5 video doesn't show up in Safari when rendered via DOMParser (rendering via innerHTML is working fine)

(note: There are many questions on video not rendering on safari. This question is about rendering video using DOMParser in Safari. Everything works fine if I user innerHTML to render the video.) I have the simplest possible HTML 5 video which is…
dasfdsa
  • 7,102
  • 8
  • 51
  • 93
4
votes
1 answer

undefined: undefined error when calling XSLTProcessor.prototype.importStylesheet

I want to prettify some XML, and I found following code (in this answer, JSFiddle). I modified it like this: const xsltDoc = new DOMParser().parseFromString([ // describes how we want to modify the XML - indent everything '
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
4
votes
2 answers

Java, XPath - how to get the entire node base on specific element

I have the following XML structure Charlie Davies 12 52 98
Tri Nguyen
  • 1,688
  • 3
  • 18
  • 46
4
votes
1 answer

How to create DOM object from html page received over XMLHttpRequest?

I'm developing a chromium extension so I have cross-host permissions for XMLHttpRequests for the domains I'm asking permissions for. I have used XMLHttpRequest and got an HTML webpage (txt/html). I want to use XPath (document.evaluate) to extract…
Dima
  • 2,012
  • 2
  • 17
  • 23
4
votes
1 answer

DOMParser - get element style

I'm trying to get a style property of an element that I parse with DOMParser. The 2 console.logs come up empty though. Any idea why this happens?
Backslash
  • 343
  • 5
  • 12
4
votes
1 answer

Java DocumentBuilder - wrong indentation in XML file

I try to write a simple XML file in Java using the DocumentBuilder. I expected the XML file to look like this:
NoBodyIsPerfect
  • 173
  • 2
  • 9
4
votes
2 answers

Difference between UnMarshaller and Parser in JAXB

Can anyone please explain the difference between UnMarshaller and Parser in JAXB. I have read like UnMarshaller is used to retrieve the value from XML document. Parser also does the same thing. Anyone please explain the difference. eg:consider the…
pandeis
  • 367
  • 2
  • 5
  • 17
4
votes
0 answers

Simple HTML Dom - Class attribute with more than one words and spaces

I try to find that: LINK What can I do to find anchors that contain in its class "four"? I try in this way: $dom->find("a[class*=four]"); But it doesn't work. I'm using the html_simple_dom library.
Donovant
  • 3,091
  • 8
  • 40
  • 68
3
votes
1 answer

Using JavaScript, how do I transform an HTML string into an array of HTML tags and text content?

I have an HTML string such as:

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

I want to convert this into a JavaScript array that looks like: ['

', '', '',…

badcoder
  • 3,624
  • 5
  • 32
  • 33
1 2
3
36 37