Juan Pablo Gomez
Juan Pablo Gomez

Reputation: 5524

convert html to xml

I have this XML returned from partial view.

<ActualizarItem>
   <NombreItem>GASEOSA 8.5 ONZAS</NombreItem>
   <OpcionesItem>&lt;div id="MenuItemEnPedido"data-role="navbar" data-iconpos="bottom" data-           theme="c"&gt;&lt;ul&gt;&lt;li&gt;&lt;a data-ajax="false" data-role="button"href="/Documentos/Docs/CondicionesMostrar?NumIdTransaccion=15199&amp;amp;NumIdConcepto=421"&gt;Condiciones&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a data-ajax="false" data-role="button" data-theme="a" href="/Documentos/Docs/DocsDetalle?StrIdDocumento=01500___00000000000000033" id="MostrarDetallePedido"&gt;Detalle&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a data-role="button" data-transition="sildedown" href="/Documentos/Docs/DocsEliminarItem?NumIdtransaccion=15199"&gt;Eliminar&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;</OpcionesItem>
</ActualizarItem>

I' want to retrieve NombreItem from that XML using jquery

function agregarItemAPedido(tcLink) {
//  Se agrega el item al documento
$.post(tcLink,
    function (data) {
        var $this = $(data);
        $(data).find('ActualizarItem').each(function () {
            alert($(this).attr('NombreItem'));
        })
    }
    );
}

But it never show the alert message. I'm was reading some posts, but none of them help me.

Upvotes: 1

Views: 290

Answers (1)

Sampson
Sampson

Reputation: 268344

The NombreItem tag is not an attribute, it's a child element.

$(data).find('NombreItem').each(function () {
    alert($(this).text());
})

Upvotes: 1

Related Questions