in Education by
I have the following XML file that I'm trying to iterate through using xml.etree: SUCCESS 1234 12 Lead ECG Obtained Oxygen I'm unable to find any of the child elements after 'message' with the following: import xml.etree.ElementTree as ET tree = ET.parse(xmlFile) root = tree.getroot() for member in root.findall('pcr'): print(member) The following child elements are listed when the following is run: for member in root: print(member) Element 'url' Element 'refcode' Element 'status' Element 'message' I'm trying to retrieve all the information under the pcr element (i.e. eCase01m, eProcedures03, eMedications03). JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can use findall() in two ways. Unhelpfully this is mentioned in two different parts of the docs: Element.findall() finds only elements with a tag which are direct children of the current element. ... Finds all matching subelements, by tag name or path. Returns a list containing all matching elements in document order. What this means is if you look for a tag, you are only searching the direct children of the current element. You can use XPath instead to look for the parts you are interested in, which will recurse through the docs looking for matches. Either of the following should do: root.findall('./message/pcrs/pcr') # Find them relative to this node root.findall('.//pcr') # Find them anywhere below the current node

Related questions

0 votes
    Which is a possible way of finding all the img elements in the document? (a) document(images) (b) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
0 votes
    I am attempting to solve a problem where if the elements in one array are squared, and all of the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    The syntax for retrieving specific elements from an XML document is ______________. (1)XMLSchema (2)XQuery (3)XPath...
asked Apr 23, 2021 in Technology by JackTerrance
0 votes
    The syntax for retrieving specific elements from an XML document is __________. (1)XML Schema (2)XQuery (3)XPath...
asked Apr 22, 2021 in Technology by JackTerrance
0 votes
    In my first class i parse my xml file like this : class ListActeurs(): fonction_key = "DiagramElements" ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    As the title said, I'm trying to implement an algorithm that finds out the distances between all pairs of nodes in given ... the edges can be considered as having weight of 1. |E|...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    What does a lyric poem lack or not have that is useful for finding the theme? 1. a title 2. a plot 3. a setting 4. complete sentences Select the correct answer from above options...
asked Dec 11, 2021 in Education by JackTerrance
0 votes
    I want to write a function that takes an array of letters as an argument and a number of those ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I want to write a function that takes an array of letters as an argument and a number of those ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    Which of these methods deletes all the elements from invoking collection? (a) clear() (b) reset() (c) ... Collections Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of this method is used to make all elements of an equal to specified value? (a) add() (b) ... The Collections Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these methods can randomize all elements in a list? (a) rand() (b) randomize() (c) shuffle( ... Collections Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Is there an 'official' way to get all input elements of a form including those outside of the form ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    Write a c program to find largest and smallest among all elements of 2-d array. Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    A determinant is chosen at random from the set of all determinant of order 2 with elements 0 or 1 only. ... chosen is nonzero. Select the correct answer from above options...
asked Nov 13, 2021 in Education by JackTerrance
...