Questions tagged [xml-parsing]

0

votes
1

answer
19

Views

Read value from xml element which tag name contains colon (:) in c#

I extracted body data from soapResponse which is given by webservice. but am not able to extract from tags which contains colon between and below data is the body response. XML Sample Data: 123456789 Abhinav used below c# code for about to get values are 123456789 and Abhinav, but it returns empty...
lucky
1

votes
1

answer
40

Views

Extract xml text when elements in between text

I have this xml file: Some text here that continues but then has some more stuff. and I need to parse it to extract its text. I am using xml.etree.ElementTree for this (see documentation). This is the simple code I use to parse and explore the file: import xml.etree.ElementTree as ET tree = ET.parse...
Pablo
0

votes
0

answer
2

Views

Exception in thread “main” org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted

I'm trying to create the xml document from java using DOM . but i'm not sure where i am missing. i'm getting the error Exception in thread "main" org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted. Please try to fix this issue. i need to...
santhoshithi
1

votes
1

answer
966

Views

Extracting attributes from XML file using xmllint

This is a part of my XML: I am trying to find the list of the strings for the systems that is called mks only using xmllint The output should give me: getuserscount setuserprivilege hasprivilege so I tried this command: xmllint --xpath 'string(//nlpcmp/word/@name)' file.xml and there was no output,...
Developer
0

votes
0

answer
17

Views

How to add a tag to an XML file in Python at a specific location?

I have an XML file with multiple comments that looks like: a b d e Programatically in Python, through xml.etree, I want to modify this file to look like this while preserving the comments: a b c d e f How can I accomplish that? tree.write(open(file, "w")) ends up overwriting the comments and tree.wr...
ion20
1

votes
2

answer
67

Views

String breaks on square bracket when parsed with lxml

I'm new to lxml parsing, and can't manage a simply parsing issue. The is a line in my xml that looks like: The IgM BCR is essential for survival of peripheral B cells [34]. In the absence of BTK B cell... So, when I execute the following code: e = open('somexml.xml', encoding='utf8') tree = etree.pa...
Paul Bobyrev
1

votes
1

answer
47

Views

Why am I getting a NullReferenceException when attempting to construct an XmlSerializer using a very simple Type with only string properties?

I've got a weird error here I don't quite understand. I have a very simple class with nothing but string properties and a couple of methods. One of those methods is a static function that returns a list of the object. When I attempt to instantiate an XmlSerializer with the type, though, I get an...
CDove
1

votes
1

answer
60

Views

How to Parse Sitemap XML Content using PHP

I have site that is on wordpress. I want to make a PHP Script that will parse XML content from the URL and show me in the form of table. I had written below PHP Script to parse the data Loc: Last Modified: Image Title: Image Location: Problem The Above PHP Script is working fine to parse Loc & L...
J. Doe
2

votes
2

answer
161

Views

Get xml file to find and replace text. PHP

I need to change texts in a XML file using PHP code. Then I created a code to: 1- get the file 2- replace the texts 3- save the file with other name. Problem is that I am having some issues to replace some text in a xml file. I am able to replace simples strings but I can not replace text with char...
JPashs
1

votes
2

answer
46

Views

read contents of all xml tags that start with a certain string

I have an xml structure where I'm looking to write a perl script that reads the content of all tags that start with a certain string. Example: This issome exampletext This is some more text This is even more text The purpose of the script is to find all nodes that start with that contain a neste...
Simon2233
1

votes
2

answer
464

Views

suppress namespace prefixes on nsxmlparser

my xml data has nodes in this format . I want to suppress the prefixes, that is when i pull the element name in nsxmlparser's delegate method it should not return as "yyy" and not as "xxx:yyy" I tries to do this [parser setDelegate:self]; [parser setShouldProcessNamespaces:NO]; [parser setShouldRepo...
thndrkiss
1

votes
2

answer
3.8k

Views

JSP c:set to value returned by x:out displays special characters code

I have an xml document. When parsing that doc I want to do . and then later This displays special characters html code instead of the character itself (ie. apostrophe becomes &#039) I have read a similar issue on that page "how-can-i-escape-special-html-characters-in-jsp" but this seems to be a s...
Adrien Be
1

votes
2

answer
1.4k

Views

XSL analyze string alternative for XSL 1.0

Is there a way to perform the analyze string operation in XSL 1.0 For example in XSL 2.0 we can have: So this will look for param1 in the Description node and replace it with a . Is it possible to do something like this with XSL 1.0?
Vinit
1

votes
1

answer
662

Views

How to check if node is an attribute

I have a node that I receive as a result of selection by XPath. Can I check if this node is an attribute? Code example: Document doc = builder.parse(new StringInputStream(xml)); XPathExpression expression = xpath.compile(path); DTMNodeList result = (DTMNodeList) expression.evaluate(doc, XPathConsta...
Dominik Kunicki
1

votes
2

answer
605

Views

How to read XML data from the header of a mixed xml/binary file in C#

I have the task to write a reader for a file format with the following specification: First section is plain xml with metadata (utf-8); Last section is a stream of 16bit values (binary); These two sections are separated by one byte with value 29 (group separator in the ASCII table). I see two ways t...
heltonbiker
1

votes
1

answer
23.5k

Views

Querying XML document using Linq

I am trying to Linq an xml document, I am unable to query the inner elements as you can see from below code what I am trying to do. I want to get all records which has a certain name... Please help. GDICT-CN 7 120 129971035565221298 GDICT-CN 7 120 129971036040828501 And now the source class Program...
Ramesh Sivaraman
1

votes
1

answer
426

Views

xsl grouping of repetitive nodes by xml element in xslt1

I have a complex xml structure that looks like : type1 description11 1 type1 description12 2 type2 description21 3 type2 description22 4 type1 description11 1 type1 description12 2 type2 description21 3 type2 description22 4 type1 description11 1 type1 description12 2 type2 description21 3 type2 de...
Polina F.
1

votes
4

answer
801

Views

How to extract details from the xml files using java?

I have the following type of XML file, 224589801 NC_000010 Homo sapiens chromosome 10, GRCh37.p10 Primary Assembly gi|224589801|gnl|ASM:GCF_000001305|10|ref|NC_000010.10||gpp|GPC_000000034.1||gnl|NCBI_GENOMES|10[224589801] 224589801 2002/08/29 2012/10/30 544 9606 135534747 live How to extract the de...
Balaram26
1

votes
1

answer
3k

Views

Add node to existing XML file

Here's my current XML file (books.xml): 123456789098 Harry Potter J K. Rowling 1 Please note that in this case, the edition is a number from 1 to 99, and that the ISBN has a length of 12 digits, contrary to the real-world concept of the book attribute. I have an "add book" form and I want to save th...
Christopher Richa
1

votes
4

answer
1.4k

Views

How do I parse my simple XML file with Java and SAX?

I am trying to parse the file below. I want to print the id and name of each passenger. Can you give me code to parse it ? Tom Cruise Tom Hanks UPDATE This is what i had tried. Code, problems etc mentioned here - Error in output of a simple SAX parser
Apple Grinder
1

votes
2

answer
801

Views

XMLREADER gives different result when xml is indented

I have the same XML in two different files. In one file the XML is indented - the other not. The XML is as follows: When using the following code I get different result with the two files: XmlReaderSettings settings = new XmlReaderSettings { IgnoreComments = true, IgnoreWhitespace = false, IgnorePro...
Jakob Brynitz
1

votes
1

answer
43

Views

Checking XML file for specified rules

Let's say I have the following xml file: 50 100 75 10 I want to be sure that xml file contains only above tags, type attribute is only type1 or type2, and amount is only integer. What should I use to validate xml file according to specified rules? Must I do it manually (parse xml file and check each...
torayeff
1

votes
2

answer
207

Views

How do you Navigate XML?

Struggling with navigating through this XML. I can not seem to define the right xPath. I am new to XML and can navigate by moving through the child nodes, but can not navigate directly to a node. Here's the code I'm using to try to read the XML: fs As FileStream = New FileStream(xmlFile, FileMode...
user38349
1

votes
2

answer
379

Views

How to search a xml file from android mobile sd card

I am having a XML file in sd card. I want to search the entire sd card and find that file. After that i have to parse that file. I have done a like below.But could not get the file.. static final String PATH = Environment.getExternalStorageDirectory() .getPath() + "/download/"; static final String F...
Android
1

votes
3

answer
1.6k

Views

Parse jenkins rest API

I am using Jenkins xml api with tree. Here is the url I am using for my locally hosted Jenkins server. http://localhost:8080/api/xml? tree=jobs[name,description,color,healthReport[score,description]] The above url shows me xml output as: build1 disabled Build stability: 2 out of the last 5 builds fa...
1

votes
1

answer
4.4k

Views

How do I escape special character to write XML using LXML

I have the following XML with invalid characters Indicate whether to support “Manage Privilege” True I read in the XML in the following way root = etree.fromstring("%s" % in_xml, parser=etree.XMLParser(recover=True)) And save the XML which i loaded in Dictionary structure, finally i made some m...
newBike
1

votes
1

answer
663

Views

SAX parsing: Encountered mixed content within text element

I'm trying to parse an XML file (representing a TV Guide) which looks like the following... BBC ONE 10029 ... Blah blah blah 2013-02-04 01:40:00 9 Entertainment 10583734 8 2013-02-04 00:15:00 The Celebrity Apprentice USA .. ... I'm using two parsers - one for channels and another for programmes but...
Squonk
1

votes
1

answer
383

Views

Forcing Scala's XML library to render “singleton tag” (e.g., <br/>) as such

If I use the loadString method to load HTML containing a tag, Scala's XML lib wants to convert that to the longer, and seemingly less standard (which unfortunately even seems to render differently than the plain-old in some browsers). I.e., the following... val xml = scala.xml.XML.loadString("Hit...
Chris W.
1

votes
4

answer
107

Views

C# Text Matching HTML

I'm trying to interact with a really crappy "web-service" (cleverly disguised as simple aspx page...) but I don't control the page so I can't tweak the output so I'm stuck with it. The format is always the same like this: Google Inc 123 North Main Hume, ACT (999) 888-8888 So, I need to parse out th...
user1406442
1

votes
3

answer
748

Views

(Python) How to get the level of a node in xml?

Is there an efficient way to get the level of each node in xml, using the python xml parser? The level of a node can also be determined by counting the closing tags while parsing the xml top-down, however, I need help in that too :). Thanks!
Curious
1

votes
2

answer
1.4k

Views

Parsing XHTML using xml.etree.ElementTree

I want to use xml.etree.ElementTree to parse an XHTML document in Python 3. The document contains   entities, so I cannot use the default parser settings. I'd like to do something similar to: with urllib.request.urlopen(BASE_URL) as url: body = url.read() parser = ET.XMLParser() parser.parser.UseFo...
prasopes
1

votes
2

answer
1.2k

Views

Building a Tree from XML File using RapidXML and c++

For a project for my c++ class, I am supposed to parse and xml file and build a binary tree from it. The file is much more dense than this but the layout is as follows: Sea Creature Fish swordfish grouper Mammal dolphin whale Land animal Mammal dog cat Bird blue jay robin I'm having a hard time figu...
K B
1

votes
1

answer
852

Views

How do I assign innerXML value to an XPathNavigator?

The following line of code is throwing a System.NotSupportedException when I try to assign a value to InnerXml: XPathNavigator dataItem = currentXPathDoc.CreateNavigator(); dataItem.MoveToChild(XPathNodeType.Element); dataItem.InnerXml = TemplateEvaluator.NormalizeUnicode(dataItem.InnerXml); This is...
Codeman
1

votes
1

answer
761

Views

Why external system entities are not working for me in Chrome, IE or Netscape?

I am attempting to replicate the example given in this answer: https://stackoverflow.com/a/5127928/356011 that illustrates using external entities to include a fragment of XML file in another XML file. doc.xml: &otherFile; otherFile.xml: this is my content When I attempt to test this by opening doc....
marathon
1

votes
1

answer
871

Views

Parsing an XML file with Nokogiri to determine the path (Ruby)

My code is supposed to "guess" the path(s) that lies before the relevant text nodes in my XML file. Relevant in this case means: text nodes nested within the recurring product/person/something tag, but not text nodes that are used outside of it. This code: @doc, items = Nokogiri.XML(@file), [] path...
1

votes
2

answer
1.3k

Views

sax parser stringbuilder only returning one line [duplicate]

This question already has an answer here: Java Sax Parser only returning one line of a tag 1 answer I've tried using a StringBuilder named object, but I'm still not getting all the CDATA from the description tag.The xml is located at Events-Ovations365: Basically it only gets the CDATA on one line...
user2230114
1

votes
1

answer
85

Views

How is a DOM tree constructed?

John Computer Technology 6 E Foo Industrial Electronics 6 E This is my XML document. I have made a tree representation of this. Is this tree representation correct or is it wrong ?
Little Child
1

votes
3

answer
2.8k

Views

Efficiently get the number of children with specific name using XML and R

Using R and the package XML I'm parsing huge XML files. As part of the data handling I need to now, in a long list of nodes, how many children of specific name each node has (the number of nodes can exceed 20.000) My approach at the moment is: nChildrenWithName
ThomasP85
1

votes
3

answer
56

Views

Representing XML tags as character ranges

Do you know of any XML libraries that convert XML markup to and from character range or offset information based on the original unmarked text? (I don't care much about the base platform of the libraries: it could be Java, Python, Perl, etc.) For instance, suppose I have this unmarked text: the cali...
Dan Halbert
1

votes
4

answer
491

Views

Reformat text in in a file linux via a bash script

I have a bunch of text files with XML like this: \n\n \n CS_REPORTING\n inbound\n 11\n It is all on one line and I want to format each \n (newline char) into an actual line break and save the file. How do I do this?
Arringar

View additional questions