Ir para conteúdo
Fórum Script Brasil
  • 0

Arquivo XML


brenocampolina

Pergunta

Boa noite pessoal,

estou com uma duvida sobre como imprimir na tela apenas os escritos sem os caracteres "<" ">";

Aqui vai uma parte do código.

Dim v_fs As FileStream = New FileStream("c:\config.xml", FileMode.Open)
        Dim v_sr As StreamReader = New StreamReader(v_fs)

        Dim v_line As String 'The current read line
        Dim v_tagName, v_tagContent As String     'The XML tagName and tag Content


        Dim result_tagName As Boolean


    'Read the config.xml file and fill some variables

    While Not v_sr.EndOfStream()

      v_line = v_sr.ReadLine()

      If v_line.IndexOf(">") = -1 Then

        Continue While

      End If

      'Get the tag name; e.g: <teste name="xxx">my content</text> will get [teste name="xxx"]
      
      v_tagName = v_line.Substring(v_line.IndexOf("<"), v_line.IndexOf(">"))
      v_tagName = v_tagName.Substring(1)

      result_tagName = StrComp(Right(v_tagName, 1), ">")
      result_tagName = Not result_tagName

      If result_tagName Then
        v_tagName = v_tagName.Substring(0, v_tagName.Length() - 1)
      End If

      Console.WriteLine(v_tagName)


      'Get the tag content; e.g: <teste>my content</text> will get [my content]


      v_tagContent = v_line.Substring(v_line.IndexOf(">"))
      v_tagContent = v_tagContent.Substring(1)


      Console.WriteLine(v_tagContent)

Essa parte do código imprime isso na tela:

Imagem executa

O XML para ser lido está aqui:

XML

Dae queria imprimir apenas o comentado, problema que não estou conseguindo e estou criando uma lógica confusa....

De qualquer forma vlws!!!

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...