I need to get empty values too from xml query which returns the links as the resultant array.There are some degrees which doesn't have links to refer.When printing, the corresponding empty results are not getting printed.
The objective is getting the links of corresponding degrees.
My code is:
postgraduatedegrees=tree.xpath('//*[@id="block-scholarly-
content"]/div/article/div/div/div//*[contains(text(),"Degree
of")]/text()')
postgraduatedegreeslinks=tree.xpath('//*[@id="block-scholarly-
content"]/div/article/div/div/div//*[contains(text(),"Degree of")]/@href')
Output:
len(postgraduatedegrees)
Out[222]: 52
len(postgraduatedegreeslinks)
Out[223]: 40
The empty values are getting removed.
Please help me to solve the issue
What I have tried:
I have tried using string(.) and textContant()
postgraduatedegreeslinks=tree.xpath('//*[@id="block-scholarly-
content"]/div/article/div/div/div//*[contains(text(),"Degree of")][@href]/text()')
for p in postgraduatedegreeslinks
print (p.extract)
Not worked for me.