Answers for "read xml java"

C#
0

java read xml

String dir = System.getProperty("user.dir");
File inputFile = new File(dir + File.separator + "dats.xml");
DocumentBuilderFactory dbFactory =
	DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(inputFile);
doc.getDocumentElement().normalize();
/*
Elimina nodos vacíos y combina adyacentes en caso de que los
hubiera
*/
Posted by: Guest on March-05-2021
0

Read XML

from bs4 import BeautifulSoup
 
soup = BeautifulSoup(open('W2Testfile.xml', encoding='utf-8'), 'lxml')
 
# Just copy from and doc and lower search or write lower case
sub_id = soup.find('SubmissionId'.lower())
# Tag and text
print(sub_id)
print(sub_id.text)
 
#---| Take out  part eg doc 2,then <find_all> of a tag that there are several of
doc_2 = soup.find('returndata', {'documentcnt': '2'})
dep_detail =  doc_2.find_all('DependentDetail'.lower())
print('-' * 30)
print(dep_detail[0].find('dependentrelationshipcd'))
print(dep_detail[0].find('dependentrelationshipcd').text)
Posted by: Guest on May-15-2021

C# Answers by Framework

Browse Popular Code Answers by Language