I would like to pass a certain parameter to an xml, so instead of being a raw xml with all the values by the creation of it, I'd like to change one with a parameter (a user input, for example).
Ideally, I was looking for something like <title> ¶m1 </title>
and be able later on to pass whatever param I would like, but I guess it cannot be done.
So like passing a parameter cannot be done (or at least from what I have searched), I thought about editing the xml after it's created.
I have searched mostly with beautifulsoup, because it is what I want to use (and what I am using). This is only a little bit of my project. for example this and this are some of my research).
So this is the function I am trying to do:
We have an xml, we find the part we want to edit, and we edit it (I know that to access it, it needs to be an integer pruebaEdit[anyString]
is not correct.
def editXMLTest():
editTest="""<?xml version="1.0" ?>
<books>
<book>
<title>moon</title>
<author>louis</author>
<price>8.50</price>
</book>
</books>
"""
soup =BeautifulSoup(editTest)
for tag in soup.find_all('title'):
print (tag.string, '\n')
#tag.string='invented title'
editTest[tag]='invented title' #I know it has to be an integer, not a string
print()
print(editTest)
My expected output should be in the xml: <title>invented title</title>
instead of <title>moon</title>
.
Edit: added this to my research