klient.ppl.cz
Useful links
  • developer
  • klient.ppl.cz
Useful links
  • developer
  • klient.ppl.cz
přepni do češtiny
    • Basic description
    • Settings and Basic functions
    • Customer
    • Shipment
    • Data Import
    • Xpath minimum
    • FAQ

    Xpath minimum

    As the attachment’s name suggests, I’ll try to describe here the minimum you need to know about XPath in order to set up data import from an XML file. I assume you already have at least a basic understanding of XML document structure. If you know nothing about XML structure or are unsure of any terms I use below, you can find an explanation online, for example here.
    If you’re reading this, you surely already know that XML has a tree structure, just like the folders on your personal computer. A file or folder path (e.g. C:\folder\file.txt) is in its basic properties very similar to an XPath expression—with the difference that XPath can’t be used to search your file system, offers many more possibilities, and can point to multiple elements or attributes at once. Here I’ll explain only the part of XPath that is closest to a file path.
    Just as a file path can be relative or absolute, an XPath to an element or attribute can also be relative or absolute. An absolute path in XPath begins at the so‑called document node (the parent of the root element). To start your search at the document node (I’ll refer to this as “starting at the document node”), you must prepend a /; otherwise, the path is relative.
    To select a specific element, simply write its name.
    To select an attribute of an element, write @ followed by the attribute name.
    Nesting in XPath is done with /.
    For example, to select the attribute cislo_domu of the ulice element nested inside the adresa element, you would write:
    adresa/ulice/@cislo_domu
    If cislo_domu were an element instead of an attribute, simply omit the @. If you’ve understood everything so far, you can also try using // instead of /, which ensures that the following element is not searched only among the direct children of the current element but among all its descendants. Furthermore, if you write * instead of an element name, you select all elements. However, use this with caution when selecting a single element or attribute, as you may accidentally select multiple nodes and end up importing all their contents (separated by spaces) into your database.
    If this description isn’t sufficient for you, you can read more, for example, here.
    Modified at 2025-07-15 12:59:01
    Previous
    Data Import
    Next
    FAQ
    Built with