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

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  [Resuelto] ¿Como escapar un CDATA en un XML?
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Resuelto] ¿Como escapar un CDATA en un XML?  (Leído 3,463 veces)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
[Resuelto] ¿Como escapar un CDATA en un XML?
« en: 9 Junio 2013, 12:04 pm »

Necesito ayuda con este xml para escapar el CDATA de la variable del RegEx (No quiero usar comillas dobles porque en otros códigos no puedo hacerlo),
no sé nada de XML y estoy perdido, muy perdido, no sé si esto tiene solución, ¿Que puedo hacer?:

Código
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.  <CodeSnippet Format="1.0.0">
  4.    <Header>
  5.      <SnippetTypes>
  6.        <SnippetType>Expansion</SnippetType>
  7.      </SnippetTypes>
  8.      <Title>
  9.         Regex match htm html
  10.      </Title>
  11.      <Author>Elektro H@cker</Author>
  12.      <Description>
  13.         Expresión regular para encontrar urls.htm
  14.      </Description>
  15.      <HelpUrl>
  16.      </HelpUrl>
  17.      <Shortcut>
  18.      </Shortcut>
  19.    </Header>
  20.    <Snippet>
  21.      <Declarations>
  22.        <Literal Editable="true">
  23.          <ID>aaaaaaaaa</ID>
  24.          <ToolTip>sfsdf</ToolTip>
  25.          <Default>
  26.          </Default>
  27.          <Function>sdfsdf</Function>
  28.        </Literal>
  29.      </Declarations>
  30.      <Code Language="vb"><![CDATA[
  31.  
  32.  
  33.  
  34.  
  35.  
  36.        Dim RegEx As New System.Text.RegularExpressions.Regex( _
  37.        <a><![CDATA[(http://|https://|www).*\.html?]]></a>.Value)
  38.  
  39.  
  40.  
  41.  
  42.  
  43. ]]></Code>
  44.    </Snippet>
  45.  </CodeSnippet>
  46. </CodeSnippets>


Según esto al final del comentario a mi no me ha quedado muy claro si hay algún "trick" para mezclar los CDATA y que funcione :S : http://stackoverflow.com/questions/223652/is-there-a-way-to-escape-a-cdata-end-token-in-xml

...¿Alguna ayuda?


« Última modificación: 9 Junio 2013, 14:06 pm por EleKtro H@cker » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: ¿Como escapar un CDATA en un XML?
« Respuesta #1 en: 9 Junio 2013, 14:05 pm »

Ya lo pude solucionar (bueno, más bien me lo solucionaron):

Código
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.  <CodeSnippet Format="1.0.0">
  4.    <Header>
  5.      <SnippetTypes>
  6.        <SnippetType>Expansion</SnippetType>
  7.      </SnippetTypes>
  8.      <Title>
  9.         Regex match htm html
  10.      </Title>
  11.      <Author>Elektro H@cker</Author>
  12.      <Description>
  13.         Expresión regular para encontrar urls.htm
  14.      </Description>
  15.      <HelpUrl>
  16.      </HelpUrl>
  17.      <Shortcut>
  18.      </Shortcut>
  19.    </Header>
  20.    <Snippet>
  21.      <Declarations>
  22.        <Literal Editable="true">
  23.          <ID>aaaaaaaaa</ID>
  24.          <ToolTip>sfsdf</ToolTip>
  25.          <Default>
  26.          </Default>
  27.          <Function>sdfsdf</Function>
  28.        </Literal>
  29.        <Literal Editable="false">
  30.          <ID>cdataend</ID>
  31.          <ToolTip>Part of the CDATA end tag.</ToolTip>
  32.          <Default>&gt;</Default>
  33.        </Literal>
  34.      </Declarations>
  35.      <Code Language="vb"><![CDATA[
  36.  
  37. #Region " RegEx Match htm-html "
  38.  
  39.    ' [ RegEx Match htm-html Function ]
  40.    '
  41.    ' // By Elektro H@cker
  42.    '
  43.    ' Examples :
  44.    ' Dim str As String = <a><![CDATA[href="http://www.mp3crank.com/the-rolling-stones/deluxe-edition.htm"]]$cdataend$</a>.Value
  45.    ' MsgBox(RegEx_Match_htm_html(str)) ' Result: http://www.mp3crank.com/the-rolling-stones/deluxe-edition.htm
  46.  
  47.    Private Function RegEx_Match_htm_html(ByVal str As String, Optional ByVal Group As Int32 = 0) As String
  48.  
  49.        ' Match criteria:
  50.        '
  51.        ' http://text.htm
  52.        ' http://text.html
  53.        ' https://text.htm
  54.        ' https://text.html
  55.        ' www.text.htm
  56.        ' www.text.html
  57.  
  58.        Dim RegEx As New System.Text.RegularExpressions.Regex( _
  59.        <a><![CDATA[(http://|https://|www).*\.html?]]$cdataend$</a>.Value)
  60.  
  61.        Return RegEx.Match(Str).Groups(Group).ToString
  62.  
  63.    End Function
  64.  
  65. #End Region
  66.  
  67. ]]></Code>
  68.    </Snippet>
  69.  </CodeSnippet>
  70. </CodeSnippets>

Saludos


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Ayuda para comprender CDATA
Desarrollo Web
sReOn_1R 1 6,128 Último mensaje 24 Septiembre 2010, 15:22 pm
por [D4N93R]
Escapar caracteres
Scripting
duende_maldito 3 2,593 Último mensaje 23 Noviembre 2011, 15:18 pm
por duende_maldito
{RESUELTO} ¿Cómo redimensiono un jPanel? {RESUELTO} « 1 2 »
Java
|Miguel| 12 10,566 Último mensaje 13 Febrero 2012, 15:11 pm
por |Miguel|
[RESUELTO] No consigo limpiar un JTable... [RESUELTO]
Java
|Miguel| 2 29,192 Último mensaje 12 Febrero 2018, 09:06 am
por shoni_isra
[RESUELTO]¿como es eso del CRC?
Programación Visual Basic
krabby 4 4,502 Último mensaje 27 Junio 2012, 04:08 am
por krabby
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines