XML Parsing

Ben Finney ben+python at benfinney.id.au
Sun Apr 5 22:39:26 EDT 2015


Sepideh Ghanavati <sepideh.gh at gmail.com> writes:

> I know basic of python and I have an xml file created from csv

What XML schema defines the document's format?

Without knowing the schema, parsing will be unreliable.

What created the document? Why is it relevant that the document was
“created from CSV”?

> which has three attributes "category", "definition" and "definition
> description".

What do you mean by “attributes”?

In Python, an attribute has a specific meaning.

In XML, an attribute has a rather different meaning.

Neither of those meanings seems to apply to “the XML document has three
attributes”. XML documents don't have attributes; differnt XML elements
in a document have different attributes.

> I want to parse through xml file and identify actors, constraints,
> principal from the text.

How are those defined in the document's schema?

> However, I am not sure what is the best way to go. Any suggestion?

You should:

* Learn some more about XML
  <URL:http://www.xmlobjective.com/the-basic-principles-of-xml/>.

* Learn exactly what formal document schema defines the document
  <URL:https://en.wikipedia.org/wiki/XML_schema>. If the document isn't
  accompanied by a specification of exactly what its schema is, you're
  going to have a difficult time.

-- 
 \        “If I melt dry ice, can I swim without getting wet?” —Steven |
  `\                                                            Wright |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list