Bonjour, j'essaie d'afficher des avatars stockés dans un fichier xml mais je ne sais pas comment faire, j'ai considéré les images comme étant des noeuds textes mais ça marche pas.
voici mon code
public final class XMLParser extends MainScreen
{
// Statics -------------------------------------------------------------------------------------
private static final String _xmlFileName = "/xml/Annuaire.xml";
public XMLParser()
{
setTitle("XML Demo");
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputStream inputStream = getClass().getResourceAsStream( _xmlFileName );
Document document = builder.parse( inputStream );
Element rootElement = document.getDocumentElement();
rootElement.normalize();
displayNode( rootElement, 0 );
}
catch ( Exception e )
{
System.out.println( e.toString() );
}
}
private void displayNode( Node node, int depth )
{
if ( node.getNodeType() == Node.ELEMENT_NODE )
{
StringBuffer buffer = new StringBuffer();
NodeList childNodes = node.getChildNodes();
int numChildren = childNodes.getLength();
Node firstChild = childNodes.item( 0 );
if ( numChildren == 1 && firstChild.getNodeType() == Node.TEXT_NODE )
{
buffer.append( firstChild.getNodeValue() );
add( new LabelField( buffer.toString() ) );
}
else
{
if(node.getNodeValue() != null)
{
buffer.append(node.getNodeValue());
add( new LabelField( buffer.toString() ) );
}
for ( int i = 0; i < numChildren; ++i )
{
displayNode( childNodes.item( i ), depth + 1 );
}
}
}
else
{
String nodeValue = node.getNodeValue();
if ( nodeValue.trim().length() != 0 )
{
HorizontalFieldManager manager = new HorizontalFieldManager();
StringBuffer buffer = new StringBuffer();
buffer.append( nodeValue );
add( manager );
manager.add(new LabelField(buffer.toString()));
}
}
}
}
est ce que je dois utiliser xslt? ou il existe des commandes DOM pour afficher les images?
Merci
[Blackberry] afficher une image dans un fichier XML
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.