简体   繁体   中英

How to Read XML Multi Tag in VB.Net

My Xml File is look like

  <MainTitle>
      <Text>BRICK kfhy;</Text>
      <Select>0</Select>

   <ContentObject> 
      <TextContent>  True </TextContent>
      <ImageContent> False </ImageContent>
    </ContentObject>

    <FONTS>
       <Name>4;Anglican;1;AndyMacarthurSH;5;Tsunami 9.0</Name> 
       <Size> 48 </Size>
       <Color> Color.Red </Color>
      <Multiple> True </Multiple>
     </FONTS>

   </MainTitle>

My Code:

   Dim _xdoc As New XDocument()
  _xdoc = XDocument.Load(_rdFl$)
   Dim GetValues = (From T In _xdoc...<MainTitle> _
                         Select Text = T.<Text>.Value,
                         TextContent = T.<TextContent>.Value,
                            FontName = T.<FontName.Value,
                               Color = T.<Color.Value)

Here I can read Text values but could not read Font,Contentobject values, I can understand that loop return the MAINTITLE sub nodes but how to get ContentObject with Fonts values here.

Dim GetValues = (From T In _xdoc...<MainTitle> _
     Select Text = T.<Text>.Value,
     TextContent = T...<ContentObject>.<TextContent>.Value,
        FontName = T...<FONTS>.<FontName.Value,
           Color = T...<FONTS>.<Color.Value)

this code is worked fine, i can read values with in the multi tag xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM