read xml file c#
XmlDocument doc = new XmlDocument();
using (StreamReader streamReader = new StreamReader(path_name, Encoding.UTF8))
{
contents = streamReader.ReadToEnd();
}
doc.LoadXml(contents);
read xml file c#
XmlDocument doc = new XmlDocument();
using (StreamReader streamReader = new StreamReader(path_name, Encoding.UTF8))
{
contents = streamReader.ReadToEnd();
}
doc.LoadXml(contents);
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)
how to read an xml file
import xmltodict as xtd
import os
xml_file_content = ""
catalog_dir = os.chdir('directory')
catalog_dir_array = os.listdir(catalog_dir)
if("nameOfFile.xml" in catalog_dir_array):
catalog_file_content = open("nameOfFile.xml", "r").read()
catalog_file_content_dict = xtd.parse(catalog_file_content)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us