elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Problema al leer un archivo XML (Solucionado)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Problema al leer un archivo XML (Solucionado)  (Leído 3,928 veces)
Zeroql


Desconectado Desconectado

Mensajes: 957


Todo lo k sucede sucede por una razon


Ver Perfil WWW
Problema al leer un archivo XML (Solucionado)
« en: 9 Julio 2010, 21:27 pm »

Buenas, buneo antes habia hecho un post de como leer este archivo..
resulta que ya lo se leer.
pero me presenta un problema cuando desea leer los keywords.
dejo el code y el archivo xml como lo tengo

Archivo XML
Código
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Languaje>
  3. <Scopes>
  4. <Scope start="Namespace" End="End Namespace"/>
  5. <Scope start="#Region" End="#End Region"/>
  6. <Scope start="Class" End="End Class"/>
  7. <Scope start="Module" End="End Module"/>
  8. <Scope start="Interface" End="End Iterface"/>
  9. <Scope start="Sub" End="End Sub"/>
  10. <Scope start="Function" End="End Function"/>
  11. <Scope start="Property" End="End Property"/>
  12. <Scope start="Get" End="End Get"/>
  13. <Scope start="Set" End="End Set"/>
  14. </Scopes>
  15. <Coments>
  16. <Coment start="'" End="\n"/>
  17. </Coments>
  18. <Constants>
  19. <Constant text="VbCr"/>
  20. <Constant text="VbCrLf"/>
  21. <Constant text="VbLf"/>
  22. </Constants>
  23. <Operators>
  24. <Pattern Id="." />
  25. <Pattern Id="!" />
  26. <Pattern Id=":" />
  27. <Pattern Id="^" />
  28. <Pattern Id="*" />
  29. <Pattern Id="/" />
  30. <Pattern Id="+" />
  31. <Pattern Id="-" />
  32. <Pattern Id="=" />
  33. <Pattern Id=";" />
  34. <Pattern Id="|" />
  35. <Pattern Id="\" />
  36. <Pattern Id="&gt;" />
  37. <Pattern Id="&lt;" />
  38. </Operators>
  39. <Keys></Keys>
  40. <Keywords>AddHandler AddressOf Alias And AndAlso Ansi As Assembly Auto Boolean ByRef Byte ByVal Call Case Catch CBool CByte CChar CDate CDec CDbl Char CInt Class CLng CObj Const CShort CSng CStr CType Currency Date Decimal Declare Default Delegate Dim DirectCast Do Double Each Else ElseIf End Enum Erase Error Event Exit Explicit False Finally For Friend Function Get GetType GoTo Global Handles If Imports In Inherits Integer Interface Implements Is Let Lib Like Long Loop Me Mod Module MustInherit MustOverride MyBase MyClass Namespace New Next Not Nothing NotInheritable NotOverridable Object On Option Optional Or OrElse Overloads Overridable Overrides ParamArray Preserve Private Property Protected Public RaiseEvent ReadOnly ReDim RemoveHandler Resume Return Select Set Shadows Shared Short Single Static Step Stop String Structure Sub SyncLock Then Throw To True Try TypeOf Unicode Until Variant When While With WithEvents WriteOnly Xor</Keywords>
  41. </Languaje>
  42.  
  43.  


Codigo que uso para leerlo
Código
  1.        ''' <summary>
  2.        ''' Leer todas palabras claves del lenguaje
  3.        ''' </summary>
  4.        Public Sub LoadSintax(ByVal pathSystem As String, ByVal nomLanguaje As String)
  5.            Dim Xml As XmlDocument
  6.            Dim NodeList As XmlNodeList
  7.            Dim Node As XmlNode
  8.            Try
  9.                Xml = New XmlDocument()
  10.                Xml.Load(pathSystem & "\" & nomLanguaje & ".xml")                   'Cargar el archivo XML con la info del lenguaje
  11.                NodeList = Xml.SelectNodes("/Languaje/Scopes/Scope")                'Cargar los nodos a leer
  12.                For Each Node In NodeList                                           'repetir hasta terminar todos los nodos
  13.                    With Node.Attributes
  14.                        sintax.StartMethod.Add(.GetNamedItem("start").Value)
  15.                        sintax.EndMethod.Add(.GetNamedItem("End").Value)
  16.                    End With
  17.                Next
  18.                NodeList = Xml.SelectNodes("/Languaje/Coments/Coment")                  'Cargar el sistema de comentarios
  19.                For Each Node In NodeList
  20.                    With Node.Attributes
  21.                        sintax.startComent.Add(.GetNamedItem("start").Value)
  22.                        sintax.endComent.Add(.GetNamedItem("End").Value)
  23.                    End With
  24.                Next
  25.                NodeList = Xml.SelectNodes("/Languaje/Constants/Constant")              'Cargar las constantes de la aplicacion
  26.                For Each Node In NodeList
  27.                    With Node.Attributes
  28.                        sintax.Constants.Add(.GetNamedItem("text").Value)
  29.                    End With
  30.                Next
  31.                NodeList = Xml.SelectNodes("/Languaje/Operators/Pattern")               'Cargar los operadores del lenguaje
  32.                For Each Node In NodeList
  33.                    With Node.Attributes
  34.                        sintax.Operators.Add(.GetNamedItem("Id").Value)
  35.                    End With
  36.                Next
  37.                Node = Xml.SelectSingleNode("/Languaje/Keywords")                       'Cargar la sintaxis de lenguaje
  38.                Dim strNode() As String = Split(Node.Value, " ")
  39.                For idx = 0 To strNode.Length - 1
  40.                    sintax.Sintaxis.Add(strNode(idx))
  41.                Next
  42.                Node = Xml.SelectSingleNode("/Languaje/Keys")                           'Cargar las palabras clave del lenguaje
  43.                strNode = Split(Node.Value, " ")
  44.                For idx = 0 To strNode.Length - 1
  45.                    sintax.KeySintax.Add(strNode(idx))
  46.                Next
  47.            Catch ex As Exception
  48.                MsgBox(ex.GetType.ToString & vbNewLine & ex.Message.ToString, vbCritical, "ERROR!")
  49.            End Try
  50.        End Sub
  51.  


que tengo mal o que tengo que cambiar para que me lea los keyword y los keys



« Última modificación: 11 Julio 2010, 15:47 pm por Zeroql » En línea

Dime y lo olvido, enseñame y lo recuerdo, involucrame y lo aprendo.
/.-ZEROQL.-\   -----  #937675#

Zeroql


Desconectado Desconectado

Mensajes: 957


Todo lo k sucede sucede por una razon


Ver Perfil WWW
Re: Problema al leer un archivo XML (Solucionado)
« Respuesta #1 en: 11 Julio 2010, 15:50 pm »

Buenas.... ya arregle el problema.

Para aquellos que experimentan talves el mismo problema les dejo la solucion

Mi problema era k no podia leer los SinlgeNode.

Cambie el code:

Código
  1. Dim strNode() As String = Split(Node.Value, " ")

POR:
Código
  1. Dim strNode() As String = Split(Node.FirstChild.Value, " ")

Espero que a alguien tambien le sirva esta solucion


En línea

Dime y lo olvido, enseñame y lo recuerdo, involucrame y lo aprendo.
/.-ZEROQL.-\   -----  #937675#

BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: Problema al leer un archivo XML (Solucionado)
« Respuesta #2 en: 12 Julio 2010, 07:44 am »


Solo un consejo esos For Each se pueden simplificar pasando a una Proceso externo  ( Función ).

Dulces Lunas!¡.
En línea

The Dark Shadow is my passion.
Zeroql


Desconectado Desconectado

Mensajes: 957


Todo lo k sucede sucede por una razon


Ver Perfil WWW
Re: Problema al leer un archivo XML (Solucionado)
« Respuesta #3 en: 12 Julio 2010, 15:31 pm »

es Cierto...
Pensaba hacerlos recursivosn inclusive.
pero este no es el unico archivo que se va  a leer y hay otros muchisimos mas grandes, decidi que era mejor usar for each.
En línea

Dime y lo olvido, enseñame y lo recuerdo, involucrame y lo aprendo.
/.-ZEROQL.-\   -----  #937675#

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Problema en C++ al leer archivo .txt « 1 2 »
Programación C/C++
javier_SL 10 12,627 Último mensaje 21 Junio 2011, 00:54 am
por Danyel_Casvill
Problema al leer archivo en Java
Java
thekill01 1 2,536 Último mensaje 27 Mayo 2012, 03:02 am
por [Case]
Problema al leer un archivo binario en C
Programación C/C++
the_jocker 5 5,062 Último mensaje 13 Agosto 2012, 01:37 am
por CSQCasimiro
problema con leer e interpretar txt
Programación C/C++
arthu16 3 2,380 Último mensaje 12 Septiembre 2013, 18:50 pm
por eferion
problema al leer gauss desde un archivo
Programación C/C++
Idmus 1 1,828 Último mensaje 14 Noviembre 2013, 19:36 pm
por Idmus
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines