IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP Discussion :

instruction pour xml Encoder utf-8


Sujet :

ASP

  1. #1
    Membre confirmé Avatar de totoche
    Inscrit en
    Janvier 2004
    Messages
    1 090
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 1 090
    Points : 558
    Points
    558
    Par défaut instruction pour xml Encoder utf-8
    Bonjour,
    Je crée un fichier xml a partir d'une page asp, mais les instructions d'entêtes
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <%@CODEPAGE="65001" LANGUAGE="VBSCRIPT" %>
    ...
    Set objFile =  objFSO.CreateTextFile(File1)
    Response.Write"<?xml version='1.0' encoding='UTF-8'?>"
    ne semblent d'aucun effet, car quand j'ouvre mon fichier xml dans ie j'ai l'erreur :
    Un caractère incorrect a été trouvé dans un contenu de texte. Erreur de traitement de la ressource
    (è...)

    il faut que j'ouvre mon fichier xml avec le bloc note que je fasse enregistrer sous 'UTF-8' , codage ANSI étant proposé par défaut, et dans ie le fichier xml s'affiche correctement
    Merci de votre aide
    La patience est un arbre aux racines amères, mais aux fruits ci-doux.

  2. #2
    LEK
    LEK est déconnecté
    Membre confirmé
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    715
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 715
    Points : 470
    Points
    470
    Par défaut
    Essaye un encodage en iso latin pour avoir droit aux accents :


  3. #3
    Membre confirmé Avatar de totoche
    Inscrit en
    Janvier 2004
    Messages
    1 090
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 1 090
    Points : 558
    Points
    558
    Par défaut
    Salut le fichier xml doit être récupérer dans flash, et lui exploite le UTF-8
    La patience est un arbre aux racines amères, mais aux fruits ci-doux.

  4. #4
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    Salut,

    MSDN ne fait pas tout à fait comme toi pour ecrire dans un fichier:
    http://msdn.microsoft.com/library/en...tetextfile.asp
    Response.write fonctionne vraiment pour ecrire dans ton fichier?

    A+
    "Winter is coming" (ma nouvelle page d'accueil)

  5. #5
    Membre confirmé Avatar de totoche
    Inscrit en
    Janvier 2004
    Messages
    1 090
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 1 090
    Points : 558
    Points
    558
    Par défaut
    Désolé pour le retard je suis sur un autre taf...

    Le probleme réside, une fois mon fichier xml généré je suis obligé de faire un enregistrer sous 'UTF-8', malgrès

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    <%@CODEPAGE="65001" LANGUAGE="VBSCRIPT" %> 
     
    <%
    File1 =  Request.ServerVariables("APPL_PHYSICAL_PATH") &_
    "fichier.xml"
     
    	'cration objet fso
    	Set fsxml=Server.CreateObject("Scripting.FileSystemObject")
     
    	'ouverture du fichier
    	Set objfile = fsxml.OpenTextFile(File1,2,TRUE) 'ASCII
    	'Ecriture Entte
    	objFile.writeLine"<?xml version='1.0' encoding='UTF-8' ?>"
     
    %>
    La patience est un arbre aux racines amères, mais aux fruits ci-doux.

  6. #6
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    Voici une fonction qui me permet de créer un fichier XML.
    Elle N'utilise PAS le file system object:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    Function ConvertRStoXML(objRS, strTopLevelNodeName, strRowNodeName)
    	on error resume next
     
    	Dim objDom
    	Dim objRoot
    	Dim objField
    	Dim objFieldValue
    	Dim objcolName
    	Dim objattTabOrder
    	Dim objPI
    	Dim x
    	Dim objRSField
    	Dim objRow
     
    	objRS.movefirst
     
    	'Instantiate the Microsoft XMLDOM.
    	Set objDom = server.CreateObject("Microsoft.XMLDOM")
    	objDom.preserveWhiteSpace = True
     
    	'Create your root element and append it to the XML document.
    	Set objRoot = objDom.createElement(strTopLevelNodeName)
    	objDom.appendChild objRoot
     
    	Do While Not objRS.EOF
    		Set objRow = objDom.CreateElement(strRowNodeName)
     
    		For Each objRSField in objRS.Fields
    			Set objField = objDom.createElement(objRSField.Name)
    			objField.Text = objRSField.Value
     
    			objField.appendChild objFieldValue
     
    			objRow.appendChild objField
    		Next 
     
    		objRoot.appendChild objRow
     
    		objRS.MoveNext
    	Loop
     
    	Set objPI = objDom.createProcessingInstruction("xml-stylesheet", "type='text/xsl' href='inc/closing.xsl'")
    	'objDom.insertBefore objPI, objDom.childNodes(0)
    	Set objPI = objDom.createProcessingInstruction("xml", "version='1.0' encoding='iso-8859-1'")
    	objDom.insertBefore objPI, objDom.childNodes(0)
     
    	'ConvertRStoXML = objDom.xml
    	objDom.Save replace(request.ServerVariables("PATH_TRANSLATED"),replace(request.ServerVariables("SCRIPT_NAME"),"/",""),"") & "MyXMLDoc.xml"
     
    	'Clean up...
    	Set objDom = Nothing
    	Set objRoot = Nothing
    	Set objField = Nothing
    	Set objFieldValue = Nothing
    	Set objcolName = Nothing
    	Set objattTabOrder = Nothing
    	Set objPI = Nothing
    End Function
    A méditer
    "Winter is coming" (ma nouvelle page d'accueil)

  7. #7
    Membre confirmé Avatar de totoche
    Inscrit en
    Janvier 2004
    Messages
    1 090
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 1 090
    Points : 558
    Points
    558
    Par défaut
    Merci,

    en effet utiliser le parser MSXML, est la solution la prise en charge de l'encodage fonctionne : createProcessingInstruction

    merci encore[/b]
    La patience est un arbre aux racines amères, mais aux fruits ci-doux.

  8. #8
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2005
    Messages
    745
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2005
    Messages : 745
    Points : 166
    Points
    166
    Par défaut
    ou pour flash utliser l'unicode (-1) avec le fso et flash le reconnait tres bien...

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. XML Encoding UTF-8 problème de majuscule
    Par rj450 dans le forum C#
    Réponses: 2
    Dernier message: 20/03/2013, 16h25
  2. Obtenir un XML Encodé UTF-8 ?
    Par CUCARACHA dans le forum C#
    Réponses: 7
    Dernier message: 26/03/2012, 14h18
  3. Lire XML encodé UTF-8 sans noeud
    Par Bobdelariege dans le forum VB.NET
    Réponses: 1
    Dernier message: 23/06/2010, 11h13
  4. Apache/PHP, xml encoding=UTF-8
    Par Shmitabidf dans le forum Apache
    Réponses: 8
    Dernier message: 27/11/2009, 11h50
  5. [1.1] Supprimer xml vers=1.0 encod=utf-8
    Par Nip dans le forum ASP.NET
    Réponses: 9
    Dernier message: 24/11/2005, 16h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo