0

I have the following xml(TEI) structure:

<?xml version="1.0"  encoding="UTF-8"?>
<?xml-model href="../schema/tei_color.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="../schema/tei_color.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
    <teiHeader>
    </teiHeader>
    <text xml:id="Z_1822-02-20_k" xml:lang="ger">
        <body>
            <div>
                <div rendition="simple:half-broken">
                    <pb n="46r" facs="#Z_1822-02-20_k_A_0001"/>
                    <cb rendition="simple:column-left"/>
                </div>
                <div>
                    <cb rendition="simple:column-right"/>
                    <p>
                        <handShift scribeRef="#Z_1822-02-20_k_scrb_1_t"/>Auf
                        <pb n="46v" facs="#Z_1822-02-20_k_A_0002"/>
                        <hi rendition="simple:italic">Heliostaten</hi> von dem Herrn Geheimen<lb/>Post-Rath
                    </p>
                </div>
            </div>
        </body>
    </text>
</TEI>

Using XPath how do I get pb elements including xml content thereunder.

Ali
  • 1
  • 2
  • This isn't valid XML. Please at least provide a minimal example that is actually valid XML. For example, what are those "some xml content" text nodes enclosed within? What XPath expressions have you tried so far? – David Denenberg Jun 21 '21 at 14:59
  • I just edited the code and reduce it to get a real example. I am new to XPath and tried //tei:pb for example. – Ali Jun 21 '21 at 16:05
  • 2
    there is no content in the element other than the "n" and "facs" attributes. If you are referring to , that is a sibling. – OldProgrammer Jun 21 '21 at 16:20

1 Answers1

0

Depending on your language where you use xpath, you can use 2 different XPath's like these:

//pb

and

//pb/following-sibling::*

Or if you can reuse //pb in a variable just use that variable extended with XPath:

./following-sibling::*

Or all in one using the union operator |:

//pb | //pb/following-sibling::*

If the xml content thereunder could be just plain text, you should use:

//pb | //pb/following-sibling::node()

The node() wil select all nodes including text()-nodes as well as element()-nodes. For more info on node() see this answer.

Siebe Jongebloed
  • 3,906
  • 2
  • 14
  • 19