Questions tagged [xml-parsing]

An XML parser goes through text documents containing XML trees and allows the information in the hierarchy to be used. Use this tag for problems implementing an XML parser or generated by the use of an existing parser in a given language.

An XML parser goes through text documents containing XML trees and allows the information in the hierarchy to be used. Use this tag for problems implementing an XML parser or generated by the use of an existing parser in a given language.

An XML parser converts an XML document into an XML DOM object - which can then be manipulated with JavaScript. All modern browsers have a built-in XML parser.

The XML document specification places requirements on what an XML processor must do and not do, but the application is outside its scope. The processor (as the specification calls it) is often referred to colloquially as an XML parser.

13856 questions
54
votes
8 answers

Java parsing XML document gives "Content not allowed in prolog." error

I am writing a program in Java that takes a custom XML file and parses it. I'm using the XML file for storage. I am getting the following error in Eclipse. [Fatal Error] :1:1: Content is not allowed in prolog. org.xml.sax.SAXParseException: Content…
ericso
  • 3,218
  • 7
  • 29
  • 36
48
votes
11 answers

An invalid XML character (Unicode: 0xc) was found

Parsing an XML file using the Java DOM parser results in: [Fatal Error] os__flag_8c.xml:103:135: An invalid XML character (Unicode: 0xc) was found in the element content of the document. org.xml.sax.SAXParseException: An invalid XML character…
Ashish
  • 1,527
  • 4
  • 17
  • 33
47
votes
3 answers

XML Error: Extra content at the end of the document

This is the XML: Sample…
electrikmilk
  • 1,013
  • 1
  • 11
  • 23
46
votes
2 answers

Can a XML element contain text and child elements at the same time?

I was looking at some xml files but didn't find the answer to my question: Can a XML element contain text and child elements at the same time? For example: textTextText text1
user1386966
  • 3,302
  • 13
  • 43
  • 72
46
votes
9 answers

Get XML only immediate children elements by name

My question is: How can I get elements directly under a specific parent element when there are other elements with the same name as a "grandchild" of the parent element. I'm using the Java DOM library to parse XML Elements and I'm running into…
kentcdodds
  • 27,113
  • 32
  • 108
  • 187
45
votes
2 answers

How to create a XML object from String in Java?

I am trying to write a code that helps me to create a XML object. For example, I will give a string as input to a function and it will return me a XMLObject. XMLObject convertToXML(String s) {} When I was searching on the net, generally I saw…
Ozer
  • 1,245
  • 4
  • 20
  • 27
44
votes
3 answers

How to prevent XXE attack (XmlDocument in .NET)

We had a security audit on our code, and they mentioned that our code is vulnerable to EXternal Entity (XXE) attack. I am using following code - string…
junni lomo
  • 769
  • 3
  • 10
  • 15
44
votes
2 answers

Difference between "findAll" and "find_all" in BeautifulSoup

I would like to parse an HTML file with Python, and the module I am using is BeautifulSoup. It is said that the function find_all is the same as findAll. I've tried both of them, but I believe they are different: import urllib, urllib2,…
Oberon
  • 628
  • 1
  • 6
  • 12
43
votes
1 answer

xpath find node that does not contain child

I'm trying to create some xpath that will find all a tags that do not contain img tags, so that something such as link matches, but does not. Of…
Ben K.
  • 1,779
  • 5
  • 18
  • 21
43
votes
4 answers

How to prevent XXE attack

We had a security audit on our code, and it mentioned that our code is vulnerable to XML EXternal Entity (XXE) attacks. Explanation XML External Entities attacks benefit from an XML feature to build documents dynamically at the time of processing.…
SANNO
  • 439
  • 2
  • 5
  • 7
40
votes
5 answers

How to fetch an attribute value from xml using powershell?

I have a list of XML files, from which I have to get the string after a particular line. In the files, I need to look for a tag Event and get the attribute value DLLRoutine. e.g. the tag would look something like below ...
Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230
39
votes
6 answers

White spaces are required between publicId and systemId

I am trying to make a ajax call to other domain locally from my computer by writing some proxy code in jsp. And this is my jQuery AJAX code that is calling proxy.jsp page. var metadata = 'https://rest-search.host.com/machine/search/meta?id='; var…
arsenal
  • 23,366
  • 85
  • 225
  • 331
38
votes
1 answer

How to parse XML with jsoup

I am trying to parse XML with jsoup, but I can't find any examples on this task. My XML document looks like this: xxx xxx
JavaCake
  • 4,075
  • 14
  • 62
  • 125
37
votes
1 answer

XML Namespace URI with HTTPS?

Is it better to have a xmlns URI with https protocol? For example this is the recommended way by the manual: Is it legal and better to use this way?
kavai77
  • 6,282
  • 7
  • 33
  • 48
37
votes
3 answers

Parse XML from URL into python object

The goodreads website has this API for accessing a user's 'shelves:' https://www.goodreads.com/review/list/20990068.xml?key=nGvCqaQ6tn9w4HNpW8kquw&v=2&shelf=toread It returns XML. I'm trying to create a django project that shows books on a shelf…
smilebomb
  • 5,123
  • 8
  • 49
  • 81