Answer the question
In order to leave comments, you need to log in
How to correctly parse lxml in Python 3 so that the data of one product is written in one line of the xls file?
How to correctly parse lxml in Python 3 so that the data of one product is written in one line of the xls file? I have an outline, but when lxml encounters an empty tag, it takes the value from the next one, and I need that when an empty tag is encountered, lxml will give the tag a value of 0.
# -*- coding: utf-8 -*- from __future__ import unicode_literals
from lxml import etree
txt = etree.parse('product.xml')
tag = etree.XPath('/doct/product/price/price/text()')
tag = tag(txt)
for l in tag:
print(l)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question