
{"id":779,"date":"2009-10-01T09:18:26","date_gmt":"2009-10-01T08:18:26","guid":{"rendered":"http:\/\/dasini.net\/blog\/?p=779"},"modified":"2009-10-01T09:23:27","modified_gmt":"2009-10-01T08:23:27","slug":"utiliser-xml-avec-mysql-5-1-part-55","status":"publish","type":"post","link":"https:\/\/dasini.net\/blog\/2009\/10\/01\/utiliser-xml-avec-mysql-5-1-part-55\/","title":{"rendered":"Utiliser XML avec MySQL 5.1 (part 5\/5)"},"content":{"rendered":"<p><!-- \t\t@page { margin: 2cm } \t\tP { margin-bottom: 0.21cm } \t\tH2 { margin-bottom: 0.21cm } \t\tH2.western { font-family: \"Arial\", sans-serif; font-size: 14pt; font-style: italic } \t\tH2.cjk { font-family: \"MS Mincho\"; font-size: 14pt; font-style: italic } \t\tH2.ctl { font-family: \"Tahoma\"; font-size: 14pt; font-style: italic } --><\/p>\n<p style=\"margin-bottom: 0cm;\">(<a title=\"Utiliser XML avec MySQL 5.1 (part 4\/5)\" href=\"http:\/\/dasini.net\/blog\/2009\/09\/16\/utiliser-xml-avec-mysql-5-1-part-45\/\">&lt;- pr\u00e9c\u00e9dent<\/a>)<\/p>\n<p style=\"margin-bottom: 0cm;\">Jusqu&rsquo;ici, la r\u00e9cup\u00e9ration des informations ne s&rsquo;est op\u00e9r\u00e9e qu&rsquo;en lisant un flux <em>XML<\/em> stock\u00e9 dans une variable. Cependant, il est \u00e9galement possible de r\u00e9cup\u00e9rer des informations <em>XML<\/em> stock\u00e9es dans la base : il suffit pour cela de remplacer la variable par le nom du champs dans lequel est enregistr\u00e9 ce flux.<\/p>\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">Comment trouver le type et les URL des flux RSS qui contiennent le mot <em>France ?<\/em><\/p>\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\"><span style=\"text-decoration: underline;\">Extraire les donn\u00e9es d&rsquo;un flux XML stock\u00e9 en base<\/span><\/p>\n<p style=\"margin-bottom: 0cm;\">\n<address style=\"margin-bottom: 0cm;\"> <\/address>\n<address style=\"margin-bottom: 0cm; text-decoration: none;\">SELECT type, extractValue( flux_rss, \u00ab\u00a0\/rss\/channel\/item\/link[ ..\/title[contains(.,&rsquo;France&rsquo;)]]\u00a0\u00bb) AS url FROM rss GROUP BY url HAVING url NOT LIKE \u00a0\u00bb\\G<\/address>\n<address style=\"margin-bottom: 0cm; text-decoration: none;\">*************************** 1. row ***************************<\/address>\n<address style=\"margin-bottom: 0cm; text-decoration: none;\">type: international<\/address>\n<address style=\"margin-bottom: 0cm; text-decoration: none;\">url: http:\/\/www.lemonde.fr\/asie-pacifique\/article\/2008\/08\/21\/en-france-le-debat-s-intensifie-sur-le-renfort-des-troupes-en-afghanistan-decide-par-m-sarkozy_1086214_3216.html?xtor=RSS-3210<\/address>\n<address style=\"margin-bottom: 0cm; text-decoration: none;\">*************************** 2. row ***************************<\/address>\n<address style=\"margin-bottom: 0cm; text-decoration: none;\">type: technologie<\/address>\n<address style=\"margin-bottom: 0cm; text-decoration: none;\">url: http:\/\/www.lemonde.fr\/aujourd-hui\/article\/2008\/08\/07\/en-france-des-adversaires-des-jo-s-expriment-en-video-sur-la-toile_1081170_3238.html?xtor=<em>RSS-651865<\/em><\/address>\n<p style=\"margin-bottom: 0cm; text-decoration: none;\">\n<p style=\"margin-bottom: 0cm; text-decoration: none;\">\n<p style=\"margin-bottom: 0cm; text-decoration: none;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">MySQL 5 impl\u00e9mente une autre commande pour pouvoir traiter des flux <em>XML<\/em>, la fonction <span style=\"text-decoration: none;\"><strong>updateXML()<\/strong><\/span>. Elle permet de modifier la sortie d&rsquo;un document <em>XML<\/em>, sans modifier ce dernier.<\/p>\n<p style=\"margin-bottom: 0cm;\">Une remarque, cette fonction ne modifie que le premier n\u0153ud trouv\u00e9 qui correspond \u00e0 l&rsquo;expression, ce qui limite son int\u00e9r\u00eat. De plus, la cha\u00eene de remplacement est fig\u00e9e, il n&rsquo;est donc pas possible de faire une transformation:<\/p>\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\"><span style=\"text-decoration: underline;\">Remplacement de donn\u00e9es XML avec updatexml<\/span><\/p>\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">SELECT updatexml(load_file( &lsquo;c:\/formateur.xml&rsquo;), &lsquo;\/opensource\/formateur[2]\/prenom&rsquo;, &lsquo;&lt;prenom&gt;aka XML fan&lt;\/prenom&gt;&rsquo;) AS result \\G<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\"> <\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">*************************** 1. row ***************************<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">result:<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;opensource&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">Les formateurs de l&rsquo;\u00e9quipe sont :<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;formateur domaines=\u00a0\u00bbMySQL PHP\u00a0\u00bb&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;nom&gt;Dasini&lt;\/nom&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;prenom&gt;Olivier&lt;\/prenom&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;\/formateur&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;formateur domaines=\u00a0\u00bbPHP XML\u00a0\u00bb&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;nom&gt;Allard&lt;\/nom&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;prenom&gt;Aka XML fan&lt;\/prenom&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;\/formateur&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;formateur domaines=\u00a0\u00bbLinux MySQL\u00a0\u00bb&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;nom&gt;Dumont&lt;\/nom&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;prenom&gt;Pierre&lt;\/prenom&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;\/formateur&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">et sont passionn\u00e9s par l&rsquo;open source.<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">&lt;\/opensource&gt;<\/address>\n<address style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">\/*Le fichier XML original n&rsquo;est pas modifi\u00e9*\/<\/address>\n<p style=\"margin-bottom: 0cm; font-weight: normal; text-decoration: none;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<h2>Conclusion<\/h2>\n<p style=\"margin-bottom: 0cm;\">Voil\u00e0 un petit panorama de l&rsquo;utilisation des fonctionnalit\u00e9s <em>XML<\/em> de <em>MySQL<\/em>. Comme nous l&rsquo;avons vu, g\u00e9n\u00e9rer le r\u00e9sultat d&rsquo;une requ\u00eate au format <em>XML<\/em> reste tr\u00e8s simple avec le client texte mysql, idem pour la g\u00e9n\u00e9ration d&rsquo;une sauvegarde (<em>mysqldump<\/em>). De plus, bien que n&rsquo;\u00e9tant pas un base de donn\u00e9es <em>XML<\/em>, ont peut ais\u00e9ment y stocker des flux <em>XML<\/em>, et les parcourir ou les modifier gr\u00e2ce aux fonctions <strong><span style=\"text-decoration: underline;\">extractValue<\/span><\/strong> et <strong><span style=\"text-decoration: underline;\">updatexml<\/span><\/strong>, et une bonne dose <span style=\"font-style: normal;\">d&rsquo;<\/span><em>XPath<\/em>. Le support de ce dernier, par MySQL, reste encore assez basique, mais ce manque sera combl\u00e9 progressivement dans les prochaines versions.<\/p>\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\">\n<p style=\"margin-bottom: 0cm;\"><em>Article co-\u00e9crit avec Fabien Allard qui est formateur et d\u00e9veloppeur certifi\u00e9 PHP, Ajax et Linux chez Anaska Alter Way Group. Fabien est \u00e9galement sp\u00e9cialiste des technologies XML.<\/em><\/p>\n<p style=\"margin-bottom: 0cm;\"><em>(<a title=\"Utiliser XML avec MySQL 5.1 (part 1\/5)\" href=\"http:\/\/dasini.net\/blog\/2009\/07\/17\/utiliser-xml-avec-mysql-5-1-part-15\/\">D\u00e9but de l&rsquo;article<\/a>)<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voil\u00e0 un petit panorama de l&rsquo;utilisation des fonctionnalit\u00e9s XML de MySQL. Comme nous l&rsquo;avons vu, g\u00e9n\u00e9rer le r\u00e9sultat d&rsquo;une requ\u00eate au format XML reste tr\u00e8s simple avec le client texte mysql, idem pour la g\u00e9n\u00e9ration d&rsquo;une sauvegarde (mysqldump). De plus, bien que n&rsquo;\u00e9tant pas un base de donn\u00e9es XML, ont peut ais\u00e9ment y stocker des flux XML, et les parcourir ou les modifier gr\u00e2ce aux fonctions extractValue et updatexml, et une bonne dose d&rsquo;XPath. Le support de ce dernier, par MySQL, reste encore assez basique, mais ce manque sera combl\u00e9 progressivement dans les prochaines versions.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"categories":[8],"tags":[151,241,152,77,78],"class_list":["post-779","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-extractvalue","tag-mysql","tag-updatexml","tag-xml","tag-xpath"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9LfWW-cz","jetpack-related-posts":[{"id":758,"url":"https:\/\/dasini.net\/blog\/2009\/09\/16\/utiliser-xml-avec-mysql-5-1-part-45\/","url_meta":{"origin":779,"position":0},"title":"Utiliser XML avec MySQL 5.1 (part 4\/5)","author":"Olivier DASINI","date":"16 septembre 2009","format":false,"excerpt":"Les fonctionnalit\u00e9s XPath de MySQL 5 MySQL 5 offre la possibilit\u00e9 de pouvoir ex\u00e9cuter des requ\u00eates XPath sur un flux XML, gr\u00e2ce \u00e0 la fonction extractValue(). Le r\u00e9sultat r\u00e9cup\u00e9r\u00e9 est la concat\u00e9nation de la valeur textuelle de chacun des n\u0153uds trouv\u00e9s (chaque valeur \u00e9tant dissoci\u00e9e des autres par un espace\u2026","rel":"","context":"Dans &quot;MySQL&quot;","block_context":{"text":"MySQL","link":"https:\/\/dasini.net\/blog\/category\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":691,"url":"https:\/\/dasini.net\/blog\/2009\/07\/29\/utiliser-xml-avec-mysql-5-1-part-25\/","url_meta":{"origin":779,"position":1},"title":"Utiliser XML avec MySQL 5.1 (part 2\/5)","author":"Olivier DASINI","date":"29 juillet 2009","format":false,"excerpt":"Ins\u00e9rer du XML dans MySQL Un fichier XML, n'est finalement qu'un fichier contenant du texte et ins\u00e9rer du texte dans un SGBDR, est loin d'\u00eatre la chose la plus difficile. Une simple requ\u00eate INSERT fait l'affaire. Cela nous donne quelque chose comme ceci : INSERT INTO ma_table (champ_texte) VALUES ('...')","rel":"","context":"Dans &quot;MySQL&quot;","block_context":{"text":"MySQL","link":"https:\/\/dasini.net\/blog\/category\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":713,"url":"https:\/\/dasini.net\/blog\/2009\/08\/10\/utiliser-xml-avec-mysql-5-1-part-35\/","url_meta":{"origin":779,"position":2},"title":"Utiliser XML avec MySQL 5.1 (part 3\/5)","author":"Olivier DASINI","date":"10 ao\u00fbt 2009","format":false,"excerpt":"Interroger un flux XML avec Xpath L'emploi de XML ne pr\u00e9senterait pas beaucoup d'int\u00e9r\u00eat sans la possibilit\u00e9 de pouvoir interroger sa structure pour acc\u00e9der \u00e0 une information particuli\u00e8re : le langage XPath r\u00e9pond \u00e0 cette attente et est (en partie du moins) aujourd'hui int\u00e9gr\u00e9 \u00e0 MySQL. Mais avant de voir\u2026","rel":"","context":"Dans &quot;MySQL&quot;","block_context":{"text":"MySQL","link":"https:\/\/dasini.net\/blog\/category\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":673,"url":"https:\/\/dasini.net\/blog\/2009\/07\/17\/utiliser-xml-avec-mysql-5-1-part-15\/","url_meta":{"origin":779,"position":3},"title":"Utiliser XML avec MySQL 5.1 (part 1\/5)","author":"Olivier DASINI","date":"17 juillet 2009","format":false,"excerpt":"MySQL avec son mod\u00e8le relationnel et XML avec son approche hi\u00e9rarchique ont en commun la vocation d'organiser et de structurer des ensembles de donn\u00e9es. En regardant de plus pr\u00e8s, ces technologies peuvent offrir des solutions compl\u00e9mentaires : * MySQL s'adapte \u00e0 merveille \u00e0 la gestion de syst\u00e8mes d'informations \u00e9ventuellement lourds\u2026","rel":"","context":"Dans &quot;MySQL&quot;","block_context":{"text":"MySQL","link":"https:\/\/dasini.net\/blog\/category\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":334,"url":"https:\/\/dasini.net\/blog\/2008\/12\/13\/les-nouveautes-de-mysql-51-part-45\/","url_meta":{"origin":779,"position":4},"title":"Les nouveaut\u00e9s de MySQL 5.1 &#8212; (part 4\/5)","author":"Olivier DASINI","date":"13 d\u00e9cembre 2008","format":false,"excerpt":"Le moteur de stockage CSV n'est pas une vraie nouveaut\u00e9. Il est disponible depuis MySQL 4.1.4 (MySQL 5.1 pour M.S. Windows). Sa particularit\u00e9 est de stocker les donn\u00e9es dans un fichier texte au format CSV (Comma Separated Values) o\u00f9 les donn\u00e9es sont s\u00e9par\u00e9es par une virgule. Les avantages sont multiples,\u2026","rel":"","context":"Dans &quot;MySQL&quot;","block_context":{"text":"MySQL","link":"https:\/\/dasini.net\/blog\/category\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":295,"url":"https:\/\/dasini.net\/blog\/2008\/12\/06\/les-nouveautes-de-mysql-51-part-35\/","url_meta":{"origin":779,"position":5},"title":"Les nouveaut\u00e9s de MySQL 5.1 &#8212; (part 3\/5)","author":"Olivier DASINI","date":"6 d\u00e9cembre 2008","format":false,"excerpt":"MySQL propose une solution de haute disponibilit\u00e9 : MySQL Cluster. Cette technologie permet de mettre en place une architecture cluster shared nothing \u00e0 l'aide de tables au format NDBCluster. Jusqu'\u00e0 MySQL 5.0, MySQL Cluster ne fonctionnait qu'enti\u00e8rement en m\u00e9moire. Ceci excluait donc certaines bases de donn\u00e9es trop volumineuses. La nouvelle\u2026","rel":"","context":"Dans &quot;MySQL&quot;","block_context":{"text":"MySQL","link":"https:\/\/dasini.net\/blog\/category\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/779","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/comments?post=779"}],"version-history":[{"count":4,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/779\/revisions"}],"predecessor-version":[{"id":782,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/779\/revisions\/782"}],"wp:attachment":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/media?parent=779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/categories?post=779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/tags?post=779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}