Python Forum
IWhat is the cause to get XPath in weird format using Python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IWhat is the cause to get XPath in weird format using Python?
#8
(May-25-2021, 04:12 PM)snippsat Wrote: I showed you how to parse W2Testfile.xml in your last Thread, both with using BS and lxml for the task.
IRSW2.xsd is used for Validation,you still miss a file for that to work efileTypes.xsd(see that is referenced in IRSW2.xsd).
# Line 11
<xsd:include schemaLocation="efileTypes.xsd"/>
from lxml import etree

xml_file = etree.parse("W2Testfile.xml")
xml_validator = etree.XMLSchema(file="IRSW2.xsd")

Thanks. I am attaching .xsd, .xml that validates to TURE.

from lxml import etree
 
xml_file = etree.parse("Test41.xml")
xml_validator = etree.XMLSchema(file="Test41.xsd")
is_valid = xml_validator.validate(xml_file)
print(is_valid)


is_valid = xml_validator.validate(xml_file)
print(is_valid)
Error:
.... lxml.etree.XMLSchemaParseError: Element '{http://www.w3.org/2001/XMLSchema}include': Failed to load the document 'efileTypes.xsd' for inclusion., line 11
How to validate an XML file with an XML schema in Python

testdata.zip contain Test41.xml. Test41.xsd, efilesTypes.xsd
.zip   testata.zip (Size: 16.37 KB / Downloads: 117)

How do I make xpath list for this .xml & .xsd?

Thanks for your help.
Reply


Messages In This Thread
RE: IWhat is the cause to get XPath in weird format using Python? - by MDRI - May-27-2021, 02:01 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Weird behaviour using if statement in python 3.10.8 mikepy 23 3,642 Jan-18-2023, 04:51 PM
Last Post: mikepy
  How do I get full XPath extract using Python? MDRI 1 2,217 Sep-18-2020, 02:13 AM
Last Post: MDRI
  python being weird justindiaz7474 0 1,376 May-05-2020, 10:19 PM
Last Post: justindiaz7474
  [split] Python beginner: Weird Syntax Error mnsaathvika 1 2,146 Jul-22-2019, 06:14 AM
Last Post: buran
  Python 3.6.5 pathlib weird behaviour when resolve a relative path on root (macOs) QbLearningPython 7 6,168 May-29-2018, 08:38 AM
Last Post: QbLearningPython
  python nested list assignment weird behavior eyalk1 2 4,459 Jan-16-2018, 07:32 PM
Last Post: wavic
  Python beginner: Weird Syntax Error mentoly 5 10,348 Oct-13-2017, 08:06 AM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020