Duda programación en C sobre archivo .xml

Iniciado por Claubn95, 16 Diciembre 2013, 13:44 PM

0 Miembros y 1 Visitante están viendo este tema.

Claubn95

Para mostrar por pantalla los caracteres que se encuentren dentro de los tags englishName del siguiente fichero XML de Facebook, ¿qué debo hacer?

El archivo se encuentra en:
http://www.facebook.com/translations/FacebookLocales.xml

Se supone que debo meter en un array tipo char este archivo .xml, para luego leer dicha variable e imprimir por pantalla la información que se encuentra dentro de esos tags englishName.

Agradecería la ayuda, puesto que llevo días razonándolo y no encuentro la forma de hallar la solución.

amchacon

Pues vas leyendo el archivo, cuando encuentres un <englishName>, entonces empiezas a mostrar por pantalla hasta que encuentre un <.

No sé, esque el algoritmo no tiene más. Otra cosa esque me preguntes como encontrar el <englishName>.
Por favor, no me manden MP con dudas. Usen el foro, gracias.

¡Visita mi programa estrella!

Rar File Missing: Esteganografía en un Rar

Claubn95

Muchas gracias. Es que en este caso se supone que con un if podría encontrar <englishName>. Lo he hecho de esta manera, y me compila pero a la hora de ejecutarlo no hace nada...

#include<stdio.h>
#include<windows.h>
#include<string.h>
int main(void){

char xml[13000]="<locales><locale><englishName>Afrikaans</englishName><codes><code><standard><name>FB</name><representation>af_ZA</representation></standard></code></codes></locale><locale><englishName>Arabic</englishName><codes><code><standard><name>FB</name><representation>ar_AR</representation></standard></code></codes></locale><locale><englishName>Azerbaijani</englishName><codes><code><standard><name>FB</name><representation>az_AZ</representation></standard></code></codes></locale><locale><englishName>Belarusian</englishName><codes><code><standard><name>FB</name><representation>be_BY</representation></standard></code></codes></locale><locale><englishName>Bulgarian</englishName><codes><code><standard><name>FB</name><representation>bg_BG</representation></standard></code></codes></locale><locale><englishName>Bengali</englishName><codes><code><standard><name>FB</name><representation>bn_IN</representation></standard></code></codes></locale><locale><englishName>Bosnian</englishName><codes><code><standard><name>FB</name><representation>bs_BA</representation></standard></code></codes></locale><locale><englishName>Catalan</englishName><codes><code><standard><name>FB</name><representation>ca_ES</representation></standard></code></codes></locale><locale><englishName>Czech</englishName><codes><code><standard><name>FB</name><representation>cs_CZ</representation></standard></code></codes></locale><locale><englishName>Welsh</englishName><codes><code><standard><name>FB</name><representation>cy_GB</representation></standard></code></codes></locale><locale><englishName>Danish</englishName><codes><code><standard><name>FB</name><representation>da_DK</representation></standard></code></codes></locale><locale><englishName>German</englishName><codes><code><standard><name>FB</name><representation>de_DE</representation></standard></code></codes></locale><locale><englishName>Greek</englishName><codes><code><standard><name>FB</name><representation>el_GR</representation></standard></code></codes></locale><locale><englishName>English (UK)</englishName><codes><code><standard><name>FB</name><representation>en_GB</representation></standard></code></codes></locale><locale><englishName>English (Pirate)</englishName><codes><code><standard><name>FB</name><representation>en_PI</representation></standard></code></codes></locale><locale><englishName>English (Upside Down)</englishName><codes><code><standard><name>FB</name><representation>en_UD</representation></standard></code></codes></locale><locale><englishName>English (US)</englishName><codes><code><standard><name>FB</name><representation>en_US</representation></standard></code></codes></locale><locale><englishName>Esperanto</englishName><codes><code><standard><name>FB</name><representation>eo_EO</representation></standard></code></codes></locale><locale><englishName>Spanish (Spain)</englishName><codes><code><standard><name>FB</name><representation>es_ES</representation></standard></code></codes></locale><locale><englishName>Spanish</englishName><codes><code><standard><name>FB</name><representation>es_LA</representation></standard></code></codes></locale><locale><englishName>Estonian</englishName><codes><code><standard><name>FB</name><representation>et_EE</representation></standard></code></codes></locale><locale><englishName>Basque</englishName><codes><code><standard><name>FB</name><representation>eu_ES</representation></standard></code></codes></locale><locale><englishName>Persian</englishName><codes><code><standard><name>FB</name><representation>fa_IR</representation></standard></code></codes></locale><locale><englishName>Leet Speak</englishName><codes><code><standard><name>FB</name><representation>fb_LT</representation></standard></code></codes></locale><locale><englishName>Finnish</englishName><codes><code><standard><name>FB</name><representation>fi_FI</representation></standard></code></codes></locale><locale><englishName>Faroese</englishName><codes><code><standard><name>FB</name><representation>fo_FO</representation></standard></code></codes></locale><locale><englishName>French (Canada)</englishName><codes><code><standard><name>FB</name><representation>fr_CA</representation></standard></code></codes></locale><locale><englishName>French (France)</englishName><codes><code><standard><name>FB</name><representation>fr_FR</representation></standard></code></codes></locale><locale><englishName>Frisian</englishName><codes><code><standard><name>FB</name><representation>fy_NL</representation></standard></code></codes></locale><locale><englishName>Irish</englishName><codes><code><standard><name>FB</name><representation>ga_IE</representation></standard></code></codes></locale><locale><englishName>Galician</englishName><codes><code><standard><name>FB</name><representation>gl_ES</representation></standard></code></codes></locale><locale><englishName>Hebrew</englishName><codes><code><standard><name>FB</name><representation>he_IL</representation></standard></code></codes></locale><locale><englishName>Hindi</englishName><codes><code><standard><name>FB</name><representation>hi_IN</representation></standard></code></codes></locale><locale><englishName>Croatian</englishName><codes><code><standard><name>FB</name><representation>hr_HR</representation></standard></code></codes></locale><locale><englishName>Hungarian</englishName><codes><code><standard><name>FB</name><representation>hu_HU</representation></standard></code></codes></locale><locale><englishName>Armenian</englishName><codes><code><standard><name>FB</name><representation>hy_AM</representation></standard></code></codes></locale><locale><englishName>Indonesian</englishName><codes><code><standard><name>FB</name><representation>id_ID</representation></standard></code></codes></locale><locale><englishName>Icelandic</englishName><codes><code><standard><name>FB</name><representation>is_IS</representation></standard></code></codes></locale><locale><englishName>Italian</englishName><codes><code><standard><name>FB</name><representation>it_IT</representation></standard></code></codes></locale><locale><englishName>Japanese</englishName><codes><code><standard><name>FB</name><representation>ja_JP</representation></standard></code></codes></locale><locale><englishName>Georgian</englishName><codes><code><standard><name>FB</name><representation>ka_GE</representation></standard></code></codes></locale><locale><englishName>Khmer</englishName><codes><code><standard><name>FB</name><representation>km_KH</representation></standard></code></codes></locale><locale><englishName>Korean</englishName><codes><code><standard><name>FB</name><representation>ko_KR</representation></standard></code></codes></locale><locale><englishName>Kurdish</englishName><codes><code><standard><name>FB</name><representation>ku_TR</representation></standard></code></codes></locale><locale><englishName>Latin</englishName><codes><code><standard><name>FB</name><representation>la_VA</representation></standard></code></codes></locale><locale><englishName>Lithuanian</englishName><codes><code><standard><name>FB</name><representation>lt_LT</representation></standard></code></codes></locale><locale><englishName>Latvian</englishName><codes><code><standard><name>FB</name><representation>lv_LV</representation></standard></code></codes></locale><locale><englishName>Macedonian</englishName><codes><code><standard><name>FB</name><representation>mk_MK</representation></standard></code></codes></locale><locale><englishName>Malayalam</englishName><codes><code><standard><name>FB</name><representation>ml_IN</representation></standard></code></codes></locale><locale><englishName>Malay</englishName><codes><code><standard><name>FB</name><representation>ms_MY</representation></standard></code></codes></locale><locale><englishName>Norwegian (bokmal)</englishName><codes><code><standard><name>FB</name><representation>nb_NO</representation></standard></code></codes></locale><locale><englishName>Nepali</englishName><codes><code><standard><name>FB</name><representation>ne_NP</representation></standard></code></codes></locale><locale><englishName>Dutch</englishName><codes><code><standard><name>FB</name><representation>nl_NL</representation></standard></code></codes></locale><locale><englishName>Norwegian (nynorsk)</englishName><codes><code><standard><name>FB</name><representation>nn_NO</representation></standard></code></codes></locale><locale><englishName>Punjabi</englishName><codes><code><standard><name>FB</name><representation>pa_IN</representation></standard></code></codes></locale><locale><englishName>Polish</englishName><codes><code><standard><name>FB</name><representation>pl_PL</representation></standard></code></codes></locale><locale><englishName>Pashto</englishName><codes><code><standard><name>FB</name><representation>ps_AF</representation></standard></code></codes></locale><locale><englishName>Portuguese (Brazil)</englishName><codes><code><standard><name>FB</name><representation>pt_BR</representation></standard></code></codes></locale><locale><englishName>Portuguese (Portugal)</englishName><codes><code><standard><name>FB</name><representation>pt_PT</representation></standard></code></codes></locale><locale><englishName>Romanian</englishName><codes><code><standard><name>FB</name><representation>ro_RO</representation></standard></code></codes></locale><locale><englishName>Russian</englishName><codes><code><standard><name>FB</name><representation>ru_RU</representation></standard></code></codes></locale><locale><englishName>Slovak</englishName><codes><code><standard><name>FB</name><representation>sk_SK</representation></standard></code></codes></locale><locale><englishName>Slovenian</englishName><codes><code><standard><name>FB</name><representation>sl_SI</representation></standard></code></codes></locale><locale><englishName>Albanian</englishName><codes><code><standard><name>FB</name><representation>sq_AL</representation></standard></code></codes></locale><locale><englishName>Serbian</englishName><codes><code><standard><name>FB</name><representation>sr_RS</representation></standard></code></codes></locale><locale><englishName>Swedish</englishName><codes><code><standard><name>FB</name><representation>sv_SE</representation></standard></code></codes></locale><locale><englishName>Swahili</englishName><codes><code><standard><name>FB</name><representation>sw_KE</representation></standard></code></codes></locale><locale><englishName>Tamil</englishName><codes><code><standard><name>FB</name><representation>ta_IN</representation></standard></code></codes></locale><locale><englishName>Telugu</englishName><codes><code><standard><name>FB</name><representation>te_IN</representation></standard></code></codes></locale><locale><englishName>Thai</englishName><codes><code><standard><name>FB</name><representation>th_TH</representation></standard></code></codes></locale><locale><englishName>Filipino</englishName><codes><code><standard><name>FB</name><representation>tl_PH</representation></standard></code></codes></locale><locale><englishName>Turkish</englishName><codes><code><standard><name>FB</name><representation>tr_TR</representation></standard></code></codes></locale><locale><englishName>Ukrainian</englishName><codes><code><standard><name>FB</name><representation>uk_UA</representation></standard></code></codes></locale><locale><englishName>Vietnamese</englishName><codes><code><standard><name>FB</name><representation>vi_VN</representation></standard></code></codes></locale><locale><englishName>Simplified Chinese (China)</englishName><codes><code><standard><name>FB</name><representation>zh_CN</representation></standard></code></codes></locale><locale><englishName>Traditional Chinese (Hong Kong)</englishName><codes><code><standard><name>FB</name><representation>zh_HK</representation></standard></code></codes></locale><locale><englishName>Traditional Chinese (Taiwan)</englishName><codes><code><standard><name>FB</name><representation>zh_TW</representation></standard></code></codes></locale></locales>";
int i;


for(i=0; i<11984; i++){
    if((xml>"<englishName>")&&(xml<"</englishName>")){
        printf("%c", xml);}
    }
   
    system("PAUSE");
}

amchacon

Primero: No necesitas la librería Windows.h
Segundo: Esto no tiene ningún sentido:
if((xml>"<englishName>")&&(xml<"</englishName>"))

Te compila porque el compilador interpetra que estas comparando dirrecciones de memoria (las cadenas de texto se identifican con dirreciones de memoria).

Lo más probable esque te ponga algun warning por hacer esto, porque es muy raro comparar dirreciones de memoria con > y <.

Tienes que leer las palabras caracter a caracter, a no ser que te ayudes con alguna función externa  :silbar:
Por favor, no me manden MP con dudas. Usen el foro, gracias.

¡Visita mi programa estrella!

Rar File Missing: Esteganografía en un Rar

0xDani

Expresiones regulares, es lo que tienes que usar.

Saludos.
I keep searching for something that I never seem to find, but maybe I won't, because I left it all behind!

I code for $$$
Hago trabajos en C/C++
Contactar por PM