XML serialization - include one XML file in another?
Question: suppose you have a XML
<rootelement>
<transaction>
<code>not found</code>
<status>404</status>
</transaction>
<data>
<item>Whatever</item>
</data>
</rootelement>
And another XML file:
<rootelement2>
<transaction>
<code>not found</code>
<status>404</status>
</tr开发者_JAVA技巧ansaction>
<searchresult>
<item>Whatever</item>
</searchresult>
</rootelement2>
Now, furthermore suppose the tags transaction
, searchresult
and data
are not present, and therefore, their child elements have a namespace instead.
(See here Serializing XML with strange namespaces?)
Is there a way I can have one class for everything transaction, one class for everything data, and one class for everything searchresult, and then create a class SearchResultRequest
which encapsulates transaction
+ its own respective content (without the enclosing tags <transaction>
and <searchresult>
),
Something like
class SearchResultRequest
{
<XML_SerializeContentOnly_Here()>
public cTransaction Transaction = new cTransaction();
<XML_SerializeContentOnly_Here()>
public cSearchResult SearchResult = new cSearchResult();
}
精彩评论