簡體   English   中英

將XML轉換為jaxb模型

[英]conversion of XML into jaxb model

下面是我的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>

更新:

這篇文章適合您: 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類。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM