xmlxpathxsdxml-namespacesoasis

Parse oasis tag from the table in the XML


I am using java Xml Xpath , I have a XML inside it there is a table something like this

      <oasis:table frame="topbot">
          <oasis:tgroup cols="6">
            <oasis:colspec colwidth="*" colnum="1" colname="col1" align="left" />
            <oasis:colspec colwidth="*" colnum="2" colname="col2" align="char" char="." />
            <oasis:colspec colwidth="*" colnum="3" colname="col3" align="left" />
            <oasis:colspec colwidth="*" colnum="4" colname="col4" align="left" />
            <oasis:colspec colwidth="*" colnum="5" colname="col5" align="left" />
            <oasis:colspec colwidth="*" colnum="6" colname="col6" align="char" char="." />
            <oasis:thead>
                <oasis:row rowsep="1">
                    <oasis:entry colname="col1" />
                    <oasis:entry colname="col2" align="center">Age</oasis:entry>
                    <oasis:entry colname="col3" align="center">Education</oasis:entry>
                    <oasis:entry colname="col4" align="center">Occupation</oasis:entry>
                    <oasis:entry colname="col5" align="center">SES</oasis:entry>
                    <oasis:entry colname="col6" align="center">ID</oasis:entry>
                </oasis:row>
            </oasis:thead>
            <oasis:tbody>
                <oasis:row>
                    <oasis:entry colname="col1">Suzan</oasis:entry>
                    <oasis:entry colname="col2">29</oasis:entry>
                    <oasis:entry colname="col3">Bachelors</oasis:entry>
                    <oasis:entry colname="col4">Homemaker</oasis:entry>
                    <oasis:entry colname="col5">Moderate</oasis:entry>
                    <oasis:entry colname="col6">2.01</oasis:entry>
                </oasis:row>
          </oasis:tbody>
        </oasis:tgroup>
     </oasis:table>

I want to parse "oasis:" tag from everywhere. I tried using NamespaceContext but it did not work.I tried "oasis" as prefix but I am not able to achieve it. Any idea how to remove these "oasis:" from everywhere in the table


Solution

  • With XPath, you can select all oasis nodes with :

    //*[contains(name(),"oasis")]