0

下面是我的 xml,我想从中生成 jaxb 模型,我的目标是从项目节点中提取数据。应该使用哪些注释或我的 jaxb 模型类的外观?提前致谢。

<channel>
    <title>VIAF Search: Roy Tennant</title>
    <link>...</link>
    <description>VIAF: Results of search: cql.any all Roy Tennant</description>
    <opensearch:totalResults>8</opensearch:totalResults>
    <opensearch:startIndex>1</opensearch:startIndex>
    <opensearch:itemsPerPage>8</opensearch:itemsPerPage>
    <opensearch:link type="application/opensearchdescription+xml" 
                     href="http://viaf.org/allFieldsSearch.xml"
                     rel="search"/>
    <opensearch:Query searchTerms="Roy Tennant" role="request"/>
    <item>...</item>
    <item>
        <title>Tennant, Jeff</title>
        <link>http://viaf.org/viaf/41080217</link>
        <pubDate>Mon, 22 Feb 2010 06:44:19 GMT</pubDate>
        <guid>http://viaf.org/viaf/41080217</guid>
    </item>
    <item>...</item>
    <item>...</item>
    <item>...</item>
    <item>...</item>
    <item>...</item>
    <item>...</item>
</channel>
4

1 回答 1

0

更新:

这篇文章是给你的:http ://chawlasandeep.com/jaxb-a-head-start/

这看起来像 RSS,架构在这里http://rss2schema.codeplex.com/releases/view/18981

接下来从模式生成模型,例如在 Maven 中

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>1.5</version>
    <executions>
        <execution>
            <id>xjc</id>
            <goals>
                <goal>xjc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <packageName>com.example.myschema</packageName> <!-- The name of your generated source package -->
    </configuration>
</plugin>

这会生成所有需要的带有所需注释的 JAXB 类。

于 2013-11-12T20:58:58.347 回答