{"id":33798,"date":"2025-11-07T06:41:01","date_gmt":"2025-11-07T03:41:01","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=33798"},"modified":"2025-11-07T06:41:01","modified_gmt":"2025-11-07T03:41:01","slug":"python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/","title":{"rendered":"Python ile XML&#8217;den JSON&#8217;a ve XML&#8217;den Dict&#8217;e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber"},"content":{"rendered":"<p><body><\/p>\n<h2>Python ile XML&#8217;den JSON&#8217;a ve XML&#8217;den Dict&#8217;e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber<\/h2>\n<h3>Giri\u015f: Veri De\u011fi\u015fiminde XML ve JSON&#8217;\u0131n Rol\u00fc<\/h3>\n<p>G\u00fcn\u00fcm\u00fcz\u00fcn ba\u011flant\u0131l\u0131 d\u00fcnyas\u0131nda, farkl\u0131 sistemler ve uygulamalar aras\u0131nda veri al\u0131\u015fveri\u015fi hayati bir \u00f6neme sahiptir. Bu veri al\u0131\u015fveri\u015fi i\u00e7in en yayg\u0131n kullan\u0131lan formatlardan ikisi XML (Extensible Markup Language) ve JSON (JavaScript Object Notation) olarak \u00f6ne \u00e7\u0131kar. Her ikisi de hiyerar\u015fik veri yap\u0131lar\u0131n\u0131 temsil etmek i\u00e7in kullan\u0131l\u0131rken, farkl\u0131 kullan\u0131m senaryolar\u0131na ve avantajlara sahiptirler.<\/p>\n<p>XML, 1990&#8217;lar\u0131n sonlar\u0131ndan bu yana kurumsal sistemlerde, belge tan\u0131mlamalar\u0131nda ve SOAP tabanl\u0131 web servislerinde yo\u011fun olarak kullan\u0131lm\u0131\u015ft\u0131r. Geni\u015fletilebilir yap\u0131s\u0131, \u015fema tan\u0131mlama yetenekleri (XSD) ve okunabilirli\u011fi sayesinde karma\u015f\u0131k veri modellerini ifade etmek i\u00e7in g\u00fc\u00e7l\u00fc bir ara\u00e7 olmu\u015ftur. Ancak, s\u00f6zdizimsel olarak daha &#8220;g\u00fcr\u00fclt\u00fcl\u00fc&#8221; olmas\u0131 ve parsellenmesinin JSON&#8217;a g\u00f6re daha fazla i\u015flem g\u00fcc\u00fc gerektirmesi gibi dezavantajlar\u0131 bulunmaktad\u0131r.<\/p>\n<p>JSON ise 2000&#8217;lerin ba\u015flar\u0131ndan itibaren, \u00f6zellikle web ve mobil uygulamalar\u0131n y\u00fckseli\u015fiyle birlikte pop\u00fclaritesini art\u0131rm\u0131\u015ft\u0131r. JavaScript ile do\u011fal uyumu, hafifli\u011fi, okunabilirli\u011fi ve daha az s\u00f6zdizimsel karma\u015f\u0131kl\u0131\u011f\u0131 sayesinde RESTful API&#8217;lerde ve modern web servislerinde standart veri de\u011fi\u015fim format\u0131 haline gelmi\u015ftir. JSON&#8217;\u0131n bu avantajlar\u0131, bir\u00e7ok eski sistemin veya veritaban\u0131n\u0131n hala XML format\u0131nda veri sa\u011flamas\u0131na ra\u011fmen, yeni nesil uygulamalar\u0131n bu verileri JSON format\u0131nda t\u00fcketme ihtiyac\u0131n\u0131 do\u011furmu\u015ftur.<\/p>\n<p>Bu durum, XML&#8217;den JSON&#8217;a veya XML&#8217;den Python s\u00f6zl\u00fc\u011f\u00fcne (dict) d\u00f6n\u00fc\u015f\u00fcm\u00fcn neden bu kadar \u00f6nemli oldu\u011funu a\u00e7\u0131klamaktad\u0131r. Python, g\u00fc\u00e7l\u00fc metin i\u015fleme yetenekleri ve zengin k\u00fct\u00fcphane ekosistemi sayesinde bu t\u00fcr d\u00f6n\u00fc\u015f\u00fcmler i\u00e7in ideal bir dildir. Bu makalede, Python kullanarak XML verilerini s\u00f6zl\u00fcklere ve JSON format\u0131na nas\u0131l d\u00f6n\u00fc\u015ft\u00fcrebilece\u011finizi, farkl\u0131 yakla\u015f\u0131mlar\u0131, k\u00fct\u00fcphaneleri ve en iyi uygulamalar\u0131 detayl\u0131 bir \u015fekilde inceleyece\u011fiz.<\/p>\n<h3>XML ve JSON Temelleri: Yap\u0131sal Farkl\u0131l\u0131klar<\/h3>\n<p>D\u00f6n\u00fc\u015f\u00fcm s\u00fcre\u00e7lerini anlamak i\u00e7in, \u00f6ncelikle XML ve JSON&#8217;\u0131n temel yap\u0131lar\u0131n\u0131 ve aralar\u0131ndaki farklar\u0131 kavramak \u00f6nemlidir.<\/p>\n<h4>XML Yap\u0131s\u0131<\/h4>\n<p>XML, veriyi etiketler (tag) kullanarak hiyerar\u015fik bir yap\u0131da d\u00fczenler. Her etiket bir element&#8217;i temsil eder ve elementler i\u00e7 i\u00e7e ge\u00e7ebilir. Elementler ayr\u0131ca \u00f6zniteliklere (attribute) ve metin i\u00e7eri\u011fine sahip olabilir.<\/p>\n<p><strong>\u00d6rnek XML:<\/strong><\/p>\n<pre><code class=\"language-xml\"><kitaplar>\n  <kitap id=\"123\" tur=\"kurgu\">\n    <baslik>D\u00f6n\u00fc\u015f\u00fcm<\/baslik>\n    <yazar>Franz Kafka<\/yazar>\n    <yil>1915<\/yil>\n    <fiyat birim=\"TL\">25.50<\/fiyat>\n    <etiketler>\n      <etiket>klasik<\/etiket>\n      <etiket>edebiyat<\/etiket>\n    <\/etiketler>\n  <\/kitap>\n  <kitap id=\"456\" tur=\"bilim\">\n    <baslik>Evrenin K\u0131sa Tarihi<\/baslik>\n    <yazar>Stephen Hawking<\/yazar>\n    <yil>1988<\/yil>\n    <fiyat birim=\"TL\">40.00<\/fiyat>\n  <\/kitap>\n<\/kitaplar><\/code><\/pre>\n<p>Bu \u00f6rnekte:<br \/>\n*   <code><kitaplar><\/code> k\u00f6k elementtir.<br \/>\n*   <code><kitap><\/code> elementleri <code>id<\/code> ve <code>tur<\/code> gibi \u00f6zniteliklere sahiptir.<br \/>\n*   <code><baslik><\/code>, <code><yazar><\/code>, <code><yil><\/code> gibi elementler metin i\u00e7eri\u011fi ta\u015f\u0131r.<br \/>\n*   <code><fiyat><\/code> elementi hem metin i\u00e7eri\u011fi hem de <code>birim<\/code> \u00f6zniteli\u011fi ta\u015f\u0131r.<br \/>\n*   <code><etiketler><\/code> gibi elementler, birden fazla <code><etiket><\/code> elementi i\u00e7erebilir.<\/p>\n<h4>JSON Yap\u0131s\u0131<\/h4>\n<p>JSON, veri objelerini anahtar-de\u011fer \u00e7iftleri (key-value pairs) olarak temsil eder. Anahtarlar her zaman dizge (string) olmal\u0131, de\u011ferler ise dizge, say\u0131, boolean, null, obje veya dizi (array) olabilir.<\/p>\n<p><strong>\u00d6rnek JSON (Yukar\u0131daki XML&#8217;in kar\u015f\u0131l\u0131\u011f\u0131):<\/strong><\/p>\n<pre><code class=\"language-json\">{\n  \"kitaplar\": {\n    \"kitap\": [\n      {\n        \"@id\": \"123\",\n        \"@tur\": \"kurgu\",\n        \"baslik\": \"D\u00f6n\u00fc\u015f\u00fcm\",\n        \"yazar\": \"Franz Kafka\",\n        \"yil\": 1915,\n        \"fiyat\": {\n          \"@birim\": \"TL\",\n          \"#text\": 25.50\n        },\n        \"etiketler\": {\n          \"etiket\": [\"klasik\", \"edebiyat\"]\n        }\n      },\n      {\n        \"@id\": \"456\",\n        \"@tur\": \"bilim\",\n        \"baslik\": \"Evrenin K\u0131sa Tarihi\",\n        \"yazar\": \"Stephen Hawking\",\n        \"yil\": 1988,\n        \"fiyat\": {\n          \"@birim\": \"TL\",\n          \"#text\": 40.00\n        }\n      }\n    ]\n  }\n}<\/code><\/pre>\n<p>Bu \u00f6rnekte:<br \/>\n*   Veri bir objeyle (<code>{}<\/code>) ba\u015flar.<br \/>\n*   <code>\"kitaplar\"<\/code> bir anahtar, de\u011feri ise ba\u015fka bir objedir.<br \/>\n*   <code>\"kitap\"<\/code> anahtar\u0131n\u0131n de\u011feri bir dizidir (<code>[]<\/code>), \u00e7\u00fcnk\u00fc birden fazla kitap vard\u0131r.<br \/>\n*   XML&#8217;deki \u00f6znitelikler genellikle JSON&#8217;da <code>@<\/code> veya ba\u015fka bir \u00f6nekle anahtar olarak temsil edilir (\u00f6rn. <code>\"@id\"<\/code>).<br \/>\n*   Bir elementin hem \u00f6zniteli\u011fi hem de metin i\u00e7eri\u011fi varsa, metin i\u00e7eri\u011fi genellikle <code>\"#text\"<\/code> gibi \u00f6zel bir anahtarla temsil edilir.<br \/>\n*   Say\u0131sal de\u011ferler (\u00f6rn. <code>1915<\/code>, <code>25.50<\/code>) JSON&#8217;da do\u011frudan say\u0131 olarak temsil edilir, dizge olarak de\u011fil.<\/p>\n<h4>Neden D\u00f6n\u00fc\u015f\u00fcm Gerekli?<\/h4>\n<p>XML&#8217;in hiyerar\u015fik yap\u0131s\u0131 ve zengin semantik yetenekleri karma\u015f\u0131k belgeler ve yap\u0131land\u0131r\u0131lm\u0131\u015f veriler i\u00e7in ideal olsa da, web tabanl\u0131 uygulamalar\u0131n \u00e7o\u011fu i\u00e7in JSON daha pratik bir se\u00e7enektir.<br \/>\n*   <strong>Hafiflik ve Performans:<\/strong> JSON&#8217;\u0131n s\u00f6zdizimi daha az karakter i\u00e7erir, bu da daha k\u00fc\u00e7\u00fck dosya boyutlar\u0131 ve daha h\u0131zl\u0131 a\u011f transferi anlam\u0131na gelir. Parsellenmesi de genellikle daha h\u0131zl\u0131d\u0131r.<br \/>\n*   <strong>JavaScript Uyumlulu\u011fu:<\/strong> JSON, JavaScript objelerinin do\u011frudan bir alt k\u00fcmesidir, bu da JavaScript uygulamalar\u0131nda veri i\u015fleme kolayl\u0131\u011f\u0131 sa\u011flar.<br \/>\n*   <strong>API Standard\u0131:<\/strong> RESTful API&#8217;lerin b\u00fcy\u00fck \u00e7o\u011funlu\u011fu veri al\u0131\u015fveri\u015fi i\u00e7in JSON&#8217;\u0131 kullan\u0131r.<br \/>\n*   <strong>Modern Geli\u015ftirme:<\/strong> Yeni geli\u015ftirilen uygulamalar\u0131n \u00e7o\u011fu, frontend&#8217;den backend&#8217;e kadar JSON tabanl\u0131 veri ak\u0131\u015flar\u0131n\u0131 benimsemi\u015ftir.<br \/>\n*   <strong>Kolayl\u0131k:<\/strong> Python gibi dillerde JSON verilerini s\u00f6zl\u00fcklere d\u00f6n\u00fc\u015ft\u00fcrmek ve i\u015flemek, XML&#8217;i i\u015flemekten genellikle daha basittir.<\/p>\n<p>Bu nedenlerle, mevcut XML tabanl\u0131 sistemlerden gelen verileri modern uygulamalarda kullanabilmek i\u00e7in XML&#8217;den JSON&#8217;a veya XML&#8217;den Python s\u00f6zl\u00fc\u011f\u00fcne d\u00f6n\u00fc\u015f\u00fcm ka\u00e7\u0131n\u0131lmaz hale gelmi\u015ftir.<\/p>\n<h3>Python ile XML&#8217;i S\u00f6zl\u00fc\u011fe (Dict) D\u00f6n\u00fc\u015ft\u00fcrme<\/h3>\n<p>Python, XML verilerini i\u015flemek i\u00e7in hem standart k\u00fct\u00fcphaneler hem de \u00fc\u00e7\u00fcnc\u00fc taraf k\u00fct\u00fcphaneler sunar. Bu b\u00f6l\u00fcmde, XML&#8217;i Python s\u00f6zl\u00fc\u011f\u00fcne d\u00f6n\u00fc\u015ft\u00fcrmenin iki ana yolunu inceleyece\u011fiz: <code>xml.etree.ElementTree<\/code> ve <code>xmltodict<\/code>.<\/p>\n<h4>Standart K\u00fct\u00fcphane: xml.etree.ElementTree<\/h4>\n<p><code>xml.etree.ElementTree<\/code> mod\u00fcl\u00fc, Python&#8217;\u0131n XML ayr\u0131\u015ft\u0131rma ve i\u015fleme i\u00e7in yerle\u015fik k\u00fct\u00fcphanesidir. Genellikle &#8220;ET&#8221; olarak k\u0131salt\u0131l\u0131r. Hafif, verimli ve g\u00fcvenli bir XML ayr\u0131\u015ft\u0131r\u0131c\u0131s\u0131d\u0131r. XML&#8217;i bir a\u011fa\u00e7 yap\u0131s\u0131 olarak temsil eder, bu da elementlere, \u00f6zniteliklere ve metin i\u00e7eri\u011fine eri\u015fimi kolayla\u015ft\u0131r\u0131r.<\/p>\n<p><strong>Temel Kullan\u0131m ve Ayr\u0131\u015ft\u0131rma:<\/strong><br \/>\n<code>ElementTree<\/code> ile XML ayr\u0131\u015ft\u0131rman\u0131n iki ana yolu vard\u0131r:<br \/>\n1.  <code>ET.parse(dosya_yolu)<\/code>: Bir XML dosyas\u0131ndan ayr\u0131\u015ft\u0131rma yapar.<br \/>\n2.  <code>ET.fromstring(xml_dizgesi)<\/code>: Bir XML dizgesinden ayr\u0131\u015ft\u0131rma yapar.<\/p>\n<p>Her iki y\u00f6ntem de k\u00f6k elementi (root element) d\u00f6nd\u00fcren bir <code>ElementTree<\/code> nesnesi veya do\u011frudan bir <code>Element<\/code> nesnesi verir.<\/p>\n<p><strong>Elementlere, \u00d6zniteliklere ve Metinlere Eri\u015fim:<\/strong><br \/>\nBir <code>Element<\/code> nesnesi a\u015fa\u011f\u0131daki \u00f6zelliklere sahiptir:<br \/>\n*   <code>tag<\/code>: Elementin etiketi (\u00f6rn. &#8220;kitap&#8221;).<br \/>\n*   <code>attrib<\/code>: Elementin \u00f6zniteliklerini i\u00e7eren bir s\u00f6zl\u00fck (\u00f6rn. <code>{'id': '123', 'tur': 'kurgu'}<\/code>).<br \/>\n*   <code>text<\/code>: Elementin metin i\u00e7eri\u011fi.<br \/>\n*   <code>tail<\/code>: Elementin kapan\u0131\u015f etiketinden sonraki metin (genellikle bo\u015f).<\/p>\n<p>Alt elementlere eri\u015fmek i\u00e7in <code>find()<\/code>, <code>findall()<\/code> veya elementin kendisini yineleyici (iterator) olarak kullanabilirsiniz.<\/p>\n<p><strong>\u00d6zyinelemeli (Recursive) Bir Fonksiyon ile XML&#8217;i S\u00f6zl\u00fc\u011fe D\u00f6n\u00fc\u015ft\u00fcrme Mant\u0131\u011f\u0131:<\/strong><br \/>\n<code>ElementTree<\/code> do\u011frudan XML&#8217;i s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015ft\u00fcren bir fonksiyon sa\u011flamaz. Bu d\u00f6n\u00fc\u015f\u00fcm\u00fc kendimiz yazmam\u0131z gerekir. Bu genellikle \u00f6zyinelemeli bir fonksiyon arac\u0131l\u0131\u011f\u0131yla yap\u0131l\u0131r. Mant\u0131k \u015fu \u015fekildedir:<br \/>\n1.  Her XML elementi bir Python s\u00f6zl\u00fc\u011f\u00fcne d\u00f6n\u00fc\u015f\u00fcr.<br \/>\n2.  Elementin \u00f6znitelikleri, s\u00f6zl\u00fc\u011f\u00fcn \u00f6zel anahtarlar\u0131 (\u00f6rn. <code>@<\/code> \u00f6nekiyle) olarak eklenir.<br \/>\n3.  Elementin metin i\u00e7eri\u011fi, s\u00f6zl\u00fc\u011f\u00fcn \u00f6zel bir anahtar\u0131 (\u00f6rn. <code>#text<\/code>) olarak eklenir.<br \/>\n4.  Alt elementler, \u00fcst elementin s\u00f6zl\u00fc\u011f\u00fcnde anahtarlar olarak yer al\u0131r. E\u011fer ayn\u0131 etikete sahip birden fazla alt element varsa, bunlar bir liste olarak tutulur.<\/p>\n<p><strong>Namespace (\u0130sim Alan\u0131) Y\u00f6netimi:<\/strong><br \/>\nXML&#8217;de isim alanlar\u0131 (namespaces) ayn\u0131 etiket adlar\u0131na sahip elementler aras\u0131nda \u00e7ak\u0131\u015fmay\u0131 \u00f6nlemek i\u00e7in kullan\u0131l\u0131r. <code>ElementTree<\/code> ile isim alanlar\u0131n\u0131 y\u00f6netmek biraz karma\u015f\u0131k olabilir. Genellikle, etiket adlar\u0131n\u0131 ayr\u0131\u015ft\u0131r\u0131rken isim alanlar\u0131n\u0131 da belirtmeniz gerekir veya <code>strip_namespace()<\/code> gibi yard\u0131mc\u0131 fonksiyonlar kullanabilirsiniz.<\/p>\n<p><strong>Kapsaml\u0131 Kod \u00d6rne\u011fi (<code>xml.etree.ElementTree<\/code> ile XML&#8217;i S\u00f6zl\u00fc\u011fe D\u00f6n\u00fc\u015ft\u00fcrme):<\/strong><\/p>\n<pre><code class=\"language-python\">import xml.etree.ElementTree as ET\nimport json\n\ndef xml_to_dict_etree(element):\n    \"\"\"\n    xml.etree.ElementTree elementini \u00f6zyinelemeli olarak Python s\u00f6zl\u00fc\u011f\u00fcne d\u00f6n\u00fc\u015ft\u00fcr\u00fcr.\n    \"\"\"\n    result = {}\n\n    # \u00d6znitelikleri i\u015fle\n    if element.attrib:\n        for attr_name, attr_value in element.attrib.items():\n            result[f\"@{attr_name}\"] = attr_value\n\n    # Alt elementleri i\u015fle\n    children = list(element)\n    if children:\n        for child in children:\n            child_dict = xml_to_dict_etree(child)\n            if child.tag in result:\n                if not isinstance(result[child.tag], list):\n                    result[child.tag] = [result[child.tag]]\n                result[child.tag].append(child_dict)\n            else:\n                result[child.tag] = child_dict\n    \n    # Metin i\u00e7eri\u011fini i\u015fle\n    if element.text and element.text.strip():\n        text_content = element.text.strip()\n        # E\u011fer sadece metin i\u00e7eri\u011fi varsa ve ba\u015fka bir \u015fey yoksa, do\u011frudan de\u011feri ata\n        # Aksi takdirde, \u00f6zel bir anahtar kullanarak metni ekle\n        if not result: # Elementin \u00f6zniteli\u011fi veya alt elementi yoksa\n            try: # Say\u0131sal bir de\u011fer mi kontrol et\n                if '.' in text_content:\n                    result = float(text_content)\n                else:\n                    result = int(text_content)\n            except ValueError:\n                result = text_content\n        else: # Elementin \u00f6zniteli\u011fi veya alt elementi varsa, metni \u00f6zel anahtarla ekle\n            try: # Say\u0131sal bir de\u011fer mi kontrol et\n                if '.' in text_content:\n                    result[\"#text\"] = float(text_content)\n                else:\n                    result[\"#text\"] = int(text_content)\n            except ValueError:\n                result[\"#text\"] = text_content\n    \n    # E\u011fer sonu\u00e7 hala bo\u015f bir s\u00f6zl\u00fckse ve metin i\u00e7eri\u011fi de yoksa, None olarak kabul et\n    if isinstance(result, dict) and not result and not (element.text and element.text.strip()):\n        return None # Bo\u015f elementleri None olarak d\u00f6nd\u00fcr\n\n    return result\n\n<h2>\u00d6rnek XML verisi<\/h2>\nxml_data = \"\"\"\n<kitaplar>\n  <kitap id=\"123\" tur=\"kurgu\">\n    <baslik>D\u00f6n\u00fc\u015f\u00fcm<\/baslik>\n    <yazar>Franz Kafka<\/yazar>\n    <yil>1915<\/yil>\n    <fiyat birim=\"TL\">25.50<\/fiyat>\n    <etiketler>\n      <etiket>klasik<\/etiket>\n      <etiket>edebiyat<\/etiket>\n      <etiket>felsefe<\/etiket>\n    <\/etiketler>\n    <yorumlar>\n        <yorum kullanici=\"ahmet\">Harika bir kitap!<\/yorum>\n        <yorum kullanici=\"ayse\">\u00c7ok etkileyici.<\/yorum>\n    <\/yorumlar>\n    <bos_element><\/bos_element>\n  <\/kitap>\n  <kitap id=\"456\" tur=\"bilim\">\n    <baslik>Evrenin K\u0131sa Tarihi<\/baslik>\n    <yazar>Stephen Hawking<\/yazar>\n    <yil>1988<\/yil>\n    <fiyat birim=\"TL\">40.00<\/fiyat>\n    <ozet>Kozmolojiye giri\u015f niteli\u011finde.<\/ozet>\n  <\/kitap>\n  <tek_element>Sadece metin.<\/tek_element>\n  <sayi_element>12345<\/sayi_element>\n  <ondalik_sayi_element>67.89<\/ondalik_sayi_element>\n<\/kitaplar>\n\"\"\"\n\n<h2>XML'i ayr\u0131\u015ft\u0131r ve k\u00f6k elementi al<\/h2>\nroot = ET.fromstring(xml_data)\n\n<h2>K\u00f6k elementi ve alt\u0131ndaki t\u00fcm yap\u0131y\u0131 s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015ft\u00fcr<\/h2>\nconverted_dict = {root.tag: xml_to_dict_etree(root)}\n\n<h2>D\u00f6n\u00fc\u015fen s\u00f6zl\u00fc\u011f\u00fc yazd\u0131r<\/h2>\nprint(\"ElementTree ile D\u00f6n\u00fc\u015fen S\u00f6zl\u00fck:\")\nprint(json.dumps(converted_dict, indent=2, ensure_ascii=False))<\/code><\/pre>\n<p>Bu \u00f6zyinelemeli fonksiyon, XML&#8217;in karma\u015f\u0131k yap\u0131s\u0131n\u0131 bir Python s\u00f6zl\u00fc\u011f\u00fcne d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in genel bir yakla\u015f\u0131md\u0131r. \u00d6znitelikler <code>@<\/code> \u00f6nekiyle, metin i\u00e7eri\u011fi ise <code>#text<\/code> anahtar\u0131yla temsil edilir. Ayn\u0131 etikete sahip birden fazla alt element bir liste i\u00e7inde toplan\u0131r. Say\u0131sal metin i\u00e7erikleri otomatik olarak <code>int<\/code> veya <code>float<\/code>&#8216;a d\u00f6n\u00fc\u015ft\u00fcr\u00fclmeye \u00e7al\u0131\u015f\u0131l\u0131r.<\/p>\n<h4>\u00dc\u00e7\u00fcnc\u00fc Parti K\u00fct\u00fcphane: xmltodict<\/h4>\n<p><code>xmltodict<\/code>, Python&#8217;da XML&#8217;i s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in \u00f6zel olarak tasarlanm\u0131\u015f pop\u00fcler ve kullan\u0131m\u0131 kolay bir \u00fc\u00e7\u00fcnc\u00fc taraf k\u00fct\u00fcphanedir. <code>ElementTree<\/code>&#8216;ye k\u0131yasla \u00e7ok daha az kodla ayn\u0131 i\u015flemi ger\u00e7ekle\u015ftirir ve karma\u015f\u0131k \u00f6zyinelemeli fonksiyonlar yazma ihtiyac\u0131n\u0131 ortadan kald\u0131r\u0131r.<\/p>\n<p><strong>Neden <code>xmltodict<\/code>? Kurulumu:<\/strong><br \/>\n<code>xmltodict<\/code>&#8216;in ana avantaj\u0131, XML&#8217;i Python s\u00f6zl\u00fc\u011f\u00fcne tek bir fonksiyon \u00e7a\u011fr\u0131s\u0131yla d\u00f6n\u00fc\u015ft\u00fcrebilmesidir. \u00d6zellikle XML&#8217;in karma\u015f\u0131k yap\u0131s\u0131n\u0131 JSON benzeri bir s\u00f6zl\u00fc\u011fe h\u0131zl\u0131ca \u00e7evirmek istedi\u011finizde \u00e7ok kullan\u0131\u015fl\u0131d\u0131r.<br \/>\nKurulumu olduk\u00e7a basittir:<\/p>\n<pre><code class=\"language-bash\">pip install xmltodict<\/code><\/pre>\n<p><strong>Basit ve H\u0131zl\u0131 D\u00f6n\u00fc\u015f\u00fcm (<code>xmltodict.parse()<\/code>):<\/strong><br \/>\n<code>xmltodict.parse()<\/code> fonksiyonu, bir XML dizgesini veya dosyas\u0131n\u0131 okuyarak do\u011frudan bir Python s\u00f6zl\u00fc\u011f\u00fc d\u00f6nd\u00fcr\u00fcr. Varsay\u0131lan olarak, \u00f6znitelikleri anahtar ad\u0131n\u0131n \u00f6n\u00fcne <code>@<\/code> koyarak, elementin metin i\u00e7eri\u011fini ise <code>\"#text\"<\/code> anahtar\u0131yla temsil eder. Ayn\u0131 etikete sahip alt elementleri otomatik olarak bir liste i\u00e7inde toplar.<\/p>\n<p><strong>\u00d6zelle\u015ftirme Se\u00e7enekleri:<\/strong><br \/>\n<code>xmltodict<\/code> \u00e7e\u015fitli \u00f6zelle\u015ftirme se\u00e7enekleri sunar:<br \/>\n*   <code>attribute_prefix<\/code>: \u00d6znitelik anahtarlar\u0131 i\u00e7in varsay\u0131lan <code>@<\/code> \u00f6nekini de\u011fi\u015ftirebilirsiniz.<br \/>\n*   <code>cdata_key<\/code>: CDATA b\u00f6l\u00fcmlerinin anahtar\u0131n\u0131 belirleyebilirsiniz.<br \/>\n*   <code>text_content<\/code>: Metin i\u00e7eri\u011fi anahtar\u0131n\u0131 de\u011fi\u015ftirebilirsiniz (varsay\u0131lan <code>\"#text\"<\/code>).<br \/>\n*   <code>force_list<\/code>: Belirli elementleri her zaman liste olarak ayr\u0131\u015ft\u0131rmaya zorlayabilirsiniz, tek bir \u00f6rne\u011fi olsa bile.<br \/>\n*   <code>process_namespaces<\/code>: \u0130sim alanlar\u0131n\u0131 i\u015fleme \u015feklini kontrol edebilirsiniz.<br \/>\n*   <code>postprocessor<\/code>: Ayr\u0131\u015ft\u0131rma sonras\u0131 \u00f6zel i\u015flemler yapmak i\u00e7in bir fonksiyon belirtebilirsiniz.<\/p>\n<p><strong>Kapsaml\u0131 Kod \u00d6rne\u011fi (<code>xmltodict<\/code> ile XML&#8217;i S\u00f6zl\u00fc\u011fe D\u00f6n\u00fc\u015ft\u00fcrme):<\/strong><\/p>\n<pre><code class=\"language-python\">import xmltodict\nimport json\n\n<h2>\u00d6rnek XML verisi (\u00f6nceki \u00f6rnekle ayn\u0131)<\/h2>\nxml_data = \"\"\"\n<kitaplar>\n  <kitap id=\"123\" tur=\"kurgu\">\n    <baslik>D\u00f6n\u00fc\u015f\u00fcm<\/baslik>\n    <yazar>Franz Kafka<\/yazar>\n    <yil>1915<\/yil>\n    <fiyat birim=\"TL\">25.50<\/fiyat>\n    <etiketler>\n      <etiket>klasik<\/etiket>\n      <etiket>edebiyat<\/etiket>\n      <etiket>felsefe<\/etiket>\n    <\/etiketler>\n    <yorumlar>\n        <yorum kullanici=\"ahmet\">Harika bir kitap!<\/yorum>\n        <yorum kullanici=\"ayse\">\u00c7ok etkileyici.<\/yorum>\n    <\/yorumlar>\n    <bos_element><\/bos_element>\n  <\/kitap>\n  <kitap id=\"456\" tur=\"bilim\">\n    <baslik>Evrenin K\u0131sa Tarihi<\/baslik>\n    <yazar>Stephen Hawking<\/yazar>\n    <yil>1988<\/yil>\n    <fiyat birim=\"TL\">40.00<\/fiyat>\n    <ozet>Kozmolojiye giri\u015f niteli\u011finde.<\/ozet>\n  <\/kitap>\n  <tek_element>Sadece metin.<\/tek_element>\n  <sayi_element>12345<\/sayi_element>\n  <ondalik_sayi_element>67.89<\/ondalik_sayi_element>\n<\/kitaplar>\n\"\"\"\n\n<h2>xmltodict ile XML'i s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015ft\u00fcr<\/h2>\nconverted_dict_xmltodict = xmltodict.parse(xml_data)\n\n<h2>D\u00f6n\u00fc\u015fen s\u00f6zl\u00fc\u011f\u00fc yazd\u0131r<\/h2>\nprint(\"\\nxmltodict ile D\u00f6n\u00fc\u015fen S\u00f6zl\u00fck:\")\nprint(json.dumps(converted_dict_xmltodict, indent=2, ensure_ascii=False))\n\n<h2>\u00d6zelle\u015ftirme \u00f6rne\u011fi: \u00d6znitelik \u00f6nekini de\u011fi\u015ftirme<\/h2>\nconverted_dict_custom_attr = xmltodict.parse(xml_data, attribute_prefix='_')\nprint(\"\\nxmltodict (\u00d6zel \u00d6znitelik \u00d6neki ile) D\u00f6n\u00fc\u015fen S\u00f6zl\u00fck:\")\nprint(json.dumps(converted_dict_custom_attr, indent=2, ensure_ascii=False))\n\n<h2>Say\u0131sal de\u011ferleri otomatik d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in bir postprocessor \u00f6rne\u011fi<\/h2>\ndef postprocessor(path, key, value):\n    try:\n        if isinstance(value, str):\n            if '.' in value:\n                return float(value)\n            return int(value)\n    except ValueError:\n        pass\n    return value\n\nconverted_dict_with_postprocessor = xmltodict.parse(xml_data, postprocessor=postprocessor)\nprint(\"\\nxmltodict (Postprocessor ile Say\u0131sal D\u00f6n\u00fc\u015f\u00fcm) D\u00f6n\u00fc\u015fen S\u00f6zl\u00fck:\")\nprint(json.dumps(converted_dict_with_postprocessor, indent=2, ensure_ascii=False))<\/code><\/pre>\n<p><code>xmltodict<\/code> ile d\u00f6n\u00fc\u015f\u00fcm\u00fcn ne kadar basit oldu\u011funu g\u00f6rebilirsiniz. Ayr\u0131ca <code>postprocessor<\/code> arg\u00fcman\u0131 ile d\u00f6n\u00fc\u015ft\u00fcr\u00fclen de\u011ferler \u00fczerinde ek i\u015flemler (\u00f6rne\u011fin say\u0131sal dizgileri say\u0131lara d\u00f6n\u00fc\u015ft\u00fcrme) yapma esnekli\u011fi sunar.<\/p>\n<h4>ElementTree ve xmltodict Kar\u015f\u0131la\u015ft\u0131rmas\u0131<\/h4>\n<p>Her iki yakla\u015f\u0131m\u0131n da kendine \u00f6zg\u00fc avantajlar\u0131 ve dezavantajlar\u0131 vard\u0131r:<\/p>\n<p>*   <strong><code>xml.etree.ElementTree<\/code>:<\/strong><br \/>\n    *   <strong>Avantajlar:<\/strong> Python&#8217;\u0131n standart k\u00fct\u00fcphanesinin bir par\u00e7as\u0131d\u0131r, ek kurulum gerektirmez. Bellek a\u00e7\u0131s\u0131ndan daha verimli olabilir, \u00f6zellikle \u00e7ok b\u00fcy\u00fck XML dosyalar\u0131n\u0131 <code>iterparse<\/code> ile i\u015flerken. XML \u00fczerinde ince taneli kontrol sa\u011flar.<br \/>\n    *   <strong>Dezavantajlar:<\/strong> XML&#8217;i do\u011frudan s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in manuel olarak \u00f6zyinelemeli bir fonksiyon yazman\u0131z gerekir, bu da daha fazla kod ve karma\u015f\u0131kl\u0131k anlam\u0131na gelir. Metin i\u00e7eri\u011fi ve \u00f6zniteliklerin s\u00f6zl\u00fckte nas\u0131l temsil edilece\u011fi konusunda standart bir kural yoktur, bu da her projede farkl\u0131 bir implementasyon gerektirebilir.<br \/>\n    *   <strong>Ne Zaman Kullan\u0131l\u0131r:<\/strong> Bellek k\u0131s\u0131tlamalar\u0131 olan ortamlarda, \u00e7ok b\u00fcy\u00fck XML dosyalar\u0131yla \u00e7al\u0131\u015f\u0131rken veya XML&#8217;den s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015f\u00fcm mant\u0131\u011f\u0131 \u00fczerinde tam kontrol sahibi olmak istedi\u011finizde.<\/p>\n<p>*   <strong><code>xmltodict<\/code>:<\/strong><br \/>\n    *   <strong>Avantajlar:<\/strong> \u00c7ok basit ve h\u0131zl\u0131 kullan\u0131m. Tek bir fonksiyon \u00e7a\u011fr\u0131s\u0131yla XML&#8217;i s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015ft\u00fcr\u00fcr. \u00d6znitelikler, metin i\u00e7eri\u011fi ve liste olu\u015fturma gibi konular\u0131 otomatik olarak ele al\u0131r. \u00d6zelle\u015ftirme se\u00e7enekleri sunar (\u00f6nekler, postprocessor).<br \/>\n    *   <strong>Dezavantajlar:<\/strong> \u00dc\u00e7\u00fcnc\u00fc taraf bir k\u00fct\u00fcphanedir, kurulum gerektirir. \u00c7ok b\u00fcy\u00fck XML dosyalar\u0131nda <code>ElementTree<\/code>&#8216;ye g\u00f6re daha fazla bellek t\u00fcketebilir, \u00e7\u00fcnk\u00fc t\u00fcm XML&#8217;i belle\u011fe y\u00fckler.<br \/>\n    *   <strong>Ne Zaman Kullan\u0131l\u0131r:<\/strong> \u00c7o\u011fu durumda, \u00f6zellikle h\u0131zl\u0131 ve kolay bir XML&#8217;den s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015f\u00fcm gerekti\u011finde. Web servislerinden gelen XML verilerini i\u015flerken veya XML&#8217;i JSON&#8217;a d\u00f6n\u00fc\u015ft\u00fcrmeden \u00f6nce bir ara ad\u0131m olarak idealdir.<\/p>\n<p>Genel olarak, h\u0131zl\u0131 ve kolay bir \u00e7\u00f6z\u00fcm ar\u0131yorsan\u0131z <code>xmltodict<\/code> tercih edilir. Ancak performans kritik uygulamalar veya \u00f6zel XML i\u015fleme gereksinimleri i\u00e7in <code>ElementTree<\/code>&#8216;yi kullanmak ve kendi d\u00f6n\u00fc\u015ft\u00fcrme mant\u0131\u011f\u0131n\u0131z\u0131 yazmak daha uygun olabilir.<\/p>\n<h3>Python ile XML&#8217;den JSON&#8217;a D\u00f6n\u00fc\u015ft\u00fcrme<\/h3>\n<p>XML&#8217;i Python s\u00f6zl\u00fc\u011f\u00fcne d\u00f6n\u00fc\u015ft\u00fcrd\u00fckten sonra, bu s\u00f6zl\u00fc\u011f\u00fc JSON format\u0131na \u00e7evirmek olduk\u00e7a basittir. Python&#8217;\u0131n yerle\u015fik <code>json<\/code> mod\u00fcl\u00fc bu i\u015flemi kolayca ger\u00e7ekle\u015ftirir.<\/p>\n<h4>xmltodict ve json Mod\u00fcl\u00fc ile Do\u011frudan D\u00f6n\u00fc\u015f\u00fcm<\/h4>\n<p>Bu, XML&#8217;den JSON&#8217;a d\u00f6n\u00fc\u015f\u00fcm i\u00e7in en yayg\u0131n ve \u00f6nerilen y\u00f6ntemdir. \u00d6nce <code>xmltodict<\/code> ile XML&#8217;i bir Python s\u00f6zl\u00fc\u011f\u00fcne d\u00f6n\u00fc\u015ft\u00fcr\u00fcr, ard\u0131ndan <code>json.dumps()<\/code> fonksiyonu ile bu s\u00f6zl\u00fc\u011f\u00fc bir JSON dizgesine \u00e7evirirsiniz.<\/p>\n<p><strong>Veri Tipi D\u00f6n\u00fc\u015f\u00fcmleri:<\/strong><br \/>\n<code>xmltodict<\/code> varsay\u0131lan olarak t\u00fcm metin i\u00e7eri\u011fini dizge olarak d\u00f6nd\u00fcr\u00fcr. Ancak, JSON genellikle say\u0131sal de\u011ferleri (int, float) ve boolean de\u011ferleri (true, false) kendi tiplerinde bekler. Bu durumda, <code>xmltodict<\/code>&#8216;in <code>postprocessor<\/code> arg\u00fcman\u0131n\u0131 kullanarak veya s\u00f6zl\u00fc\u011f\u00fc JSON&#8217;a d\u00f6n\u00fc\u015ft\u00fcrmeden \u00f6nce manuel olarak veri tiplerini d\u00f6n\u00fc\u015ft\u00fcrebilirsiniz. <code>json.dumps()<\/code> fonksiyonu, Python say\u0131lar\u0131n\u0131 ve boolean de\u011ferlerini do\u011fru JSON tiplerine otomatik olarak e\u015fler.<\/p>\n<p><strong>Kod \u00d6rne\u011fi:<\/strong><\/p>\n<pre><code class=\"language-python\">import xmltodict\nimport json\n\nxml_data = \"\"\"\n<urunler>\n  <urun id=\"A101\">\n    <ad>Laptop<\/ad>\n    <fiyat para_birimi=\"USD\">1200.50<\/fiyat>\n    <stok>true<\/stok>\n    <adet>10<\/adet>\n    <ozellikler>\n      <ozellik>H\u0131zl\u0131 \u0130\u015flemci<\/ozellik>\n      <ozellik>Y\u00fcksek RAM<\/ozellik>\n    <\/ozellikler>\n  <\/urun>\n  <urun id=\"B202\">\n    <ad>Mouse<\/ad>\n    <fiyat para_birimi=\"EUR\">25.00<\/fiyat>\n    <stok>false<\/st0ok>\n    <adet>0<\/adet>\n  <\/urun>\n<\/urunler>\n\"\"\"\n\n<h2>1. Ad\u0131m: xmltodict ile XML'i Python s\u00f6zl\u00fc\u011f\u00fcne d\u00f6n\u00fc\u015ft\u00fcr<\/h2>\n<h2>Say\u0131sal ve boolean de\u011ferleri otomatik d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in postprocessor kullan<\/h2>\ndef type_converter(path, key, value):\n    if isinstance(value, str):\n        if value.lower() == 'true':\n            return True\n        if value.lower() == 'false':\n            return False\n        try:\n            if '.' in value:\n                return float(value)\n            return int(value)\n        except ValueError:\n            pass\n    return value\n\ndict_from_xml = xmltodict.parse(xml_data, postprocessor=type_converter)\n\n<h2>2. Ad\u0131m: json.dumps() ile s\u00f6zl\u00fc\u011f\u00fc JSON dizgesine \u00e7evir<\/h2>\njson_output = json.dumps(dict_from_xml, indent=2, ensure_ascii=False)\n\nprint(\"xmltodict ve json mod\u00fcl\u00fc ile XML'den JSON'a D\u00f6n\u00fc\u015f\u00fcm:\")\nprint(json_output)<\/code><\/pre>\n<p>Bu \u00f6rnekte, <code>type_converter<\/code> ad\u0131nda bir <code>postprocessor<\/code> fonksiyonu tan\u0131mlayarak, XML&#8217;deki &#8220;true&#8221;, &#8220;false&#8221; dizgilerini boolean&#8217;a ve say\u0131sal dizgileri (tam say\u0131 veya ondal\u0131kl\u0131) uygun say\u0131 tiplerine d\u00f6n\u00fc\u015ft\u00fcrd\u00fck. Bu, daha anlaml\u0131 bir JSON \u00e7\u0131kt\u0131s\u0131 elde etmemizi sa\u011flar.<\/p>\n<h4>ElementTree Kullanarak Ad\u0131m Ad\u0131m D\u00f6n\u00fc\u015f\u00fcm<\/h4>\n<p>E\u011fer <code>xmltodict<\/code> kullanmak istemiyorsan\u0131z veya <code>ElementTree<\/code> ile zaten bir s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015ft\u00fcrme fonksiyonunuz varsa, bu s\u00f6zl\u00fc\u011f\u00fc de <code>json.dumps()<\/code> ile JSON&#8217;a \u00e7evirebilirsiniz.<\/p>\n<p><strong>Kod \u00d6rne\u011fi (ElementTree ile \u00f6nce dict&#8217;e, sonra JSON&#8217;a):<\/strong><\/p>\n<pre><code class=\"language-python\">import xml.etree.ElementTree as ET\nimport json\n\n<h2>xml_to_dict_etree fonksiyonunu yukar\u0131daki ElementTree b\u00f6l\u00fcm\u00fcnden buraya kopyalay\u0131n<\/h2>\ndef xml_to_dict_etree(element):\n    result = {}\n    if element.attrib:\n        for attr_name, attr_value in element.attrib.items():\n            result[f\"@{attr_name}\"] = attr_value\n    \n    children = list(element)\n    if children:\n        for child in children:\n            child_dict = xml_to_dict_etree(child)\n            if child.tag in result:\n                if not isinstance(result[child.tag], list):\n                    result[child.tag] = [result[child.tag]]\n                result[child.tag].append(child_dict)\n            else:\n                result[child.tag] = child_dict\n    \n    if element.text and element.text.strip():\n        text_content = element.text.strip()\n        if not result:\n            try:\n                if '.' in text_content:\n                    result = float(text_content)\n                else:\n                    result = int(text_content)\n            except ValueError:\n                result = text_content\n        else:\n            try:\n                if '.' in text_content:\n                    result[\"#text\"] = float(text_content)\n                else:\n                    result[\"#text\"] = int(text_content)\n            except ValueError:\n                result[\"#text\"] = text_content\n    \n    if isinstance(result, dict) and not result and not (element.text and element.text.strip()):\n        return None \n    return result\n\nxml_data = \"\"\"\n<urunler>\n  <urun id=\"A101\">\n    <ad>Laptop<\/ad>\n    <fiyat para_birimi=\"USD\">1200.50<\/fiyat>\n    <stok>true<\/stok>\n    <adet>10<\/adet>\n    <ozellikler>\n      <ozellik>H\u0131zl\u0131 \u0130\u015flemci<\/ozellik>\n      <ozellik>Y\u00fcksek RAM<\/ozellik>\n    <\/ozellikler>\n  <\/urun>\n  <urun id=\"B202\">\n    <ad>Mouse<\/ad>\n    <fiyat para_birimi=\"EUR\">25.00<\/fiyat>\n    <stok>false<\/stok>\n    <adet>0<\/adet>\n  <\/urun>\n<\/urunler>\n\"\"\"\n\n<h2>1. Ad\u0131m: ElementTree ile XML'i ayr\u0131\u015ft\u0131r ve s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015ft\u00fcr<\/h2>\nroot = ET.fromstring(xml_data)\ndict_from_xml_etree = {root.tag: xml_to_dict_etree(root)}\n\n<h2>2. Ad\u0131m: json.dumps() ile s\u00f6zl\u00fc\u011f\u00fc JSON dizgesine \u00e7evir<\/h2>\njson_output_etree = json.dumps(dict_from_xml_etree, indent=2, ensure_ascii=False)\n\nprint(\"\\nElementTree ve json mod\u00fcl\u00fc ile XML'den JSON'a D\u00f6n\u00fc\u015f\u00fcm:\")\nprint(json_output_etree)<\/code><\/pre>\n<p>Bu yakla\u015f\u0131m, <code>xmltodict<\/code>&#8216;e g\u00f6re daha fazla kod gerektirse de, d\u00f6n\u00fc\u015f\u00fcm s\u00fcrecinin her ad\u0131m\u0131nda daha fazla kontrol sa\u011flar. \u00d6rne\u011fin, XML&#8217;den s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015f\u00fcm mant\u0131\u011f\u0131n\u0131za \u00f6zel kurallar ekleyebilir, belirli elementleri tamamen atlayabilir veya farkl\u0131 bir \u015fekilde temsil edebilirsiniz.<\/p>\n<h4>D\u00f6n\u00fc\u015f\u00fcm S\u0131ras\u0131nda Dikkat Edilmesi Gerekenler<\/h4>\n<p>*   <strong>Bo\u015f Elementler:<\/strong> <code><bos_element\/><\/code> veya <code><bos_element><\/bos_element><\/code> gibi bo\u015f elementler, JSON&#8217;da genellikle <code>null<\/code> veya bo\u015f bir dizge (<code>\"\"<\/code>) olarak temsil edilebilir. <code>xmltodict<\/code> varsay\u0131lan olarak bo\u015f elementleri <code>None<\/code> olarak d\u00f6nd\u00fcr\u00fcr.<br \/>\n*   <strong>CDATA B\u00f6l\u00fcmleri:<\/strong> CDATA b\u00f6l\u00fcmleri, XML ayr\u0131\u015ft\u0131r\u0131c\u0131s\u0131n\u0131n i\u00e7indeki metni i\u015flemeden ge\u00e7mesini sa\u011flar. JSON&#8217;a d\u00f6n\u00fc\u015ft\u00fcr\u00fcl\u00fcrken, bu i\u00e7erik genellikle normal metin gibi ele al\u0131n\u0131r. <code>xmltodict<\/code>&#8216;in <code>cdata_key<\/code> parametresi ile nas\u0131l i\u015flenece\u011fini kontrol edebilirsiniz.<br \/>\n*   <strong>Yorumlar:<\/strong> XML yorumlar\u0131 (<code><!-- yorum --><\/code>) genellikle JSON d\u00f6n\u00fc\u015f\u00fcm\u00fcnde tamamen g\u00f6z ard\u0131 edilir.<br \/>\n*   <strong>Veri Tipi \u00c7\u0131kar\u0131m\u0131 (Type Inference) ve \u00d6zelle\u015ftirme:<\/strong> XML, veri tipleri hakk\u0131nda do\u011frudan bilgi i\u00e7ermez (her \u015fey dizge olarak kabul edilir). JSON ise g\u00fc\u00e7l\u00fc tip deste\u011fine sahiptir. XML&#8217;den JSON&#8217;a d\u00f6n\u00fc\u015f\u00fcmde, say\u0131sal dizgileri (\u00f6rn. &#8220;123&#8221;, &#8220;25.50&#8221;) <code>int<\/code> veya <code>float<\/code>&#8216;a, &#8220;true&#8221;\/&#8221;false&#8221; dizgilerini <code>bool<\/code>&#8216;a d\u00f6n\u00fc\u015ft\u00fcrmek genellikle istenir. Yukar\u0131daki <code>postprocessor<\/code> \u00f6rne\u011fi bu duruma iyi bir \u00e7\u00f6z\u00fcmd\u00fcr.<br \/>\n*   <strong>Encoding (Kodlama) Sorunlar\u0131:<\/strong> XML dosyas\u0131n\u0131n kodlamas\u0131 (\u00f6rn. UTF-8, ISO-8859-1) ile Python&#8217;\u0131n ve JSON&#8217;\u0131n bekledi\u011fi kodlama aras\u0131nda uyumsuzluklar olabilir. <code>xml.etree.ElementTree<\/code> ve <code>xmltodict<\/code> genellikle bu durumu otomatik olarak y\u00f6netir, ancak sorun ya\u015farsan\u0131z <code>encoding<\/code> parametresini kontrol etmeniz gerekebilir. <code>json.dumps()<\/code> fonksiyonunda <code>ensure_ascii=False<\/code> kullanmak, T\u00fcrk\u00e7e karakterlerin do\u011fru \u015fekilde g\u00f6sterilmesini sa\u011flar.<\/p>\n<h3>Geli\u015fmi\u015f Konular ve En \u0130yi Uygulamalar<\/h3>\n<h4>B\u00fcy\u00fck XML Dosyalar\u0131 \u0130\u00e7in Performans<\/h4>\n<p>E\u011fer gigabaytlarca b\u00fcy\u00fckl\u00fckte XML dosyalar\u0131yla \u00e7al\u0131\u015f\u0131yorsan\u0131z, t\u00fcm dosyay\u0131 belle\u011fe y\u00fcklemek bellek d\u0131\u015f\u0131 (out-of-memory) hatalar\u0131na yol a\u00e7abilir. Bu t\u00fcr durumlarda <code>xml.etree.ElementTree<\/code>&#8216;nin <code>iterparse<\/code> fonksiyonu veya SAX (Simple API for XML) ayr\u0131\u015ft\u0131r\u0131c\u0131lar\u0131 daha uygun olabilir.<br \/>\n<code>iterparse<\/code>, XML dosyas\u0131n\u0131 element element ayr\u0131\u015ft\u0131r\u0131r ve her bir elementin ba\u015flang\u0131\u00e7 veya biti\u015f olay\u0131n\u0131 tetikledi\u011finde i\u015flem yapman\u0131z\u0131 sa\u011flar. Bu sayede, t\u00fcm XML a\u011fac\u0131n\u0131 bellekte tutmak yerine, sadece o an i\u015flenen elementin verilerini tutars\u0131n\u0131z.<\/p>\n<p><strong><code>iterparse<\/code> \u00d6rne\u011fi:<\/strong><\/p>\n<pre><code class=\"language-python\">import xml.etree.ElementTree as ET\nimport json\n\nxml_large_data = \"\"\"\n<veri>\n  <kayit id=\"1\">\n    <isim>Ali<\/isim>\n    <yas>30<\/yas>\n  <\/kayit>\n  <kayit id=\"2\">\n    <isim>Ay\u015fe<\/isim>\n    <yas>25<\/yas>\n  <\/kayit>\n  <!-- ... binlerce kay\u0131t daha ... -->\n<\/veri>\n\"\"\"\n<h2>B\u00fcy\u00fck XML dosyas\u0131n\u0131 sim\u00fcle etmek i\u00e7in<\/h2>\n<h2>with open('large_data.xml', 'w', encoding='utf-8') as f:<\/h2>\n<h2>f.write('<veri>')<\/h2>\n<h2>for i in range(100000): # 100 bin kay\u0131t<\/h2>\n<h2>f.write(f'<kayit id=\"{i}\"><isim>Ki\u015fi {i}<\/isim><yas>{20 + (i % 50)}<\/yas><\/kayit>')<\/h2>\n<h2>f.write('<\/veri>')<\/h2>\n\n<h2>Ger\u00e7ek bir dosya ile kullanmak i\u00e7in:<\/h2>\n<h2>context = ET.iterparse('large_data.xml', events=('end',))<\/h2>\n\n<h2>Dizge ile kullanmak i\u00e7in:<\/h2>\nfrom io import StringIO\ncontext = ET.iterparse(StringIO(xml_large_data), events=('end',))\n\nrecords = []\nfor event, elem in context:\n    if elem.tag == 'kayit':\n        record = {\n            \"@id\": elem.attrib.get('id'),\n            \"isim\": elem.find('isim').text if elem.find('isim') is not None else None,\n            \"yas\": int(elem.find('yas').text) if elem.find('yas') is not None else None\n        }\n        records.append(record)\n        elem.clear() # Bellek t\u00fcketimini azaltmak i\u00e7in i\u015flenen elementi temizle\n\n<h2>Sonucu JSON olarak yazd\u0131r<\/h2>\nprint(\"\\niterparse ile i\u015flenen kay\u0131tlar:\")\nprint(json.dumps({\"veri\": {\"kayit\": records}}, indent=2, ensure_ascii=False))<\/code><\/pre>\n<p>Bu yakla\u015f\u0131m, \u00f6zellikle her bir ana elementin (\u00f6rne\u011fin <code><kayit><\/code>) i\u015flenip hemen bellekteki yerinin bo\u015falt\u0131lmas\u0131 gereken senaryolarda \u00e7ok etkilidir.<\/p>\n<h4>Hata Y\u00f6netimi ve Ge\u00e7ersiz XML<\/h4>\n<p>XML ayr\u0131\u015ft\u0131rma s\u0131ras\u0131nda hatalarla kar\u015f\u0131la\u015fmak yayg\u0131nd\u0131r, \u00f6zellikle XML verisi d\u0131\u015f kaynaklardan geliyorsa. Yanl\u0131\u015f bi\u00e7imlendirilmi\u015f XML (malformed XML) <code>ET.fromstring()<\/code> veya <code>ET.parse()<\/code> \u00e7a\u011fr\u0131ld\u0131\u011f\u0131nda <code>xml.etree.ElementTree.ParseError<\/code> istisnas\u0131na yol a\u00e7ar. Bu t\u00fcr durumlar\u0131 <code>try-except<\/code> bloklar\u0131 ile ele almak \u00f6nemlidir.<\/p>\n<pre><code class=\"language-python\">import xml.etree.ElementTree as ET\nimport xmltodict\n\nmalformed_xml = \"<kitap><baslik>Hatal\u0131 XML<\/baslik><yazar>...<\/yazar>\" # Kapan\u0131\u015f etiketi eksik\n\ntry:\n    root = ET.fromstring(malformed_xml)\n    # \u0130\u015fleme devam et\nexcept ET.ParseError as e:\n    print(f\"ElementTree ayr\u0131\u015ft\u0131rma hatas\u0131: {e}\")\n\ntry:\n    dict_data = xmltodict.parse(malformed_xml)\n    # \u0130\u015fleme devam et\nexcept xmltodict.expat.ExpatError as e: # xmltodict de Expat tabanl\u0131 hata verir\n    print(f\"xmltodict ayr\u0131\u015ft\u0131rma hatas\u0131: {e}\")<\/code><\/pre>\n<p>XML&#8217;in bir \u015femaya (XSD) g\u00f6re ge\u00e7erli olup olmad\u0131\u011f\u0131n\u0131 kontrol etmek, verinin yap\u0131sal do\u011frulu\u011funu sa\u011flamak i\u00e7in \u00f6nemlidir. Python&#8217;da <code>lxml<\/code> gibi k\u00fct\u00fcphaneler XSD do\u011frulamas\u0131 yapabilir.<\/p>\n<h4>D\u00f6n\u00fc\u015f\u00fcm Mant\u0131\u011f\u0131n\u0131 \u00d6zelle\u015ftirme<\/h4>\n<p>Bazen, varsay\u0131lan XML&#8217;den s\u00f6zl\u00fc\u011fe\/JSON&#8217;a d\u00f6n\u00fc\u015f\u00fcm kurallar\u0131 ihtiya\u00e7lar\u0131n\u0131z\u0131 kar\u015f\u0131lamayabilir. \u00d6rne\u011fin, belirli bir elementin i\u00e7eri\u011fini farkl\u0131 bir anahtarla kaydetmek, baz\u0131 elementleri tamamen atlamak veya belirli \u00f6zniteliklerin de\u011ferlerini \u00f6zel bir formata d\u00f6n\u00fc\u015ft\u00fcrmek isteyebilirsiniz.<br \/>\nBu t\u00fcr durumlarda:<br \/>\n*   <code>xml.etree.ElementTree<\/code> kullan\u0131yorsan\u0131z, kendi \u00f6zyinelemeli fonksiyonunuzu ihtiya\u00e7lar\u0131n\u0131za g\u00f6re tamamen \u00f6zelle\u015ftirebilirsiniz.<br \/>\n*   <code>xmltodict<\/code> kullan\u0131yorsan\u0131z, <code>postprocessor<\/code> arg\u00fcman\u0131 ve di\u011fer \u00f6zelle\u015ftirme se\u00e7enekleri size b\u00fcy\u00fck esneklik sa\u011flar. Daha karma\u015f\u0131k senaryolar i\u00e7in, <code>xmltodict<\/code>&#8216;in \u00e7\u0131kt\u0131s\u0131 \u00fczerinde ikincil bir i\u015flem (post-processing) yaparak istedi\u011finiz son JSON yap\u0131s\u0131n\u0131 elde edebilirsiniz.<\/p>\n<h4>G\u00fcvenlik \u0130pu\u00e7lar\u0131<\/h4>\n<p>G\u00fcvenilmeyen kaynaklardan gelen XML verilerini i\u015flerken dikkatli olmak \u00f6nemlidir. XML, XXE (XML External Entity) sald\u0131r\u0131lar\u0131 gibi g\u00fcvenlik a\u00e7\u0131klar\u0131na yol a\u00e7abilir. Bu sald\u0131r\u0131lar, XML ayr\u0131\u015ft\u0131r\u0131c\u0131s\u0131n\u0131n harici varl\u0131klara (external entities) eri\u015fmesine izin vererek hassas veri s\u0131z\u0131nt\u0131lar\u0131na veya hizmet reddi (DoS) sald\u0131r\u0131lar\u0131na neden olabilir.<br \/>\n*   <code>xml.etree.ElementTree<\/code> varsay\u0131lan olarak XXE sald\u0131r\u0131lar\u0131na kar\u015f\u0131 g\u00fcvenlidir (harici varl\u0131klar\u0131 i\u015flemez).<br \/>\n*   <code>xmltodict<\/code>, <code>xml.etree.ElementTree<\/code> \u00fczerine in\u015fa edildi\u011fi i\u00e7in genellikle g\u00fcvenlidir. Ancak, yine de g\u00fcncel Python ve k\u00fct\u00fcphane versiyonlar\u0131n\u0131 kullanmak \u00f6nemlidir.<br \/>\n*   E\u011fer <code>defusedxml<\/code> gibi k\u00fct\u00fcphaneler kullan\u0131yorsan\u0131z, bunlar XML&#8217;in potansiyel g\u00fcvenlik a\u00e7\u0131klar\u0131n\u0131 kapatmak i\u00e7in ek \u00f6nlemler sunar.<\/p>\n<h3>Sonu\u00e7<\/h3>\n<p>Python, XML verilerini s\u00f6zl\u00fcklere ve JSON format\u0131na d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in g\u00fc\u00e7l\u00fc ve esnek ara\u00e7lar sunar. Bu makalede, iki ana yakla\u015f\u0131m\u0131 ele ald\u0131k: Python&#8217;\u0131n standart <code>xml.etree.ElementTree<\/code> mod\u00fcl\u00fc ve pop\u00fcler \u00fc\u00e7\u00fcnc\u00fc taraf <code>xmltodict<\/code> k\u00fct\u00fcphanesi.<\/p>\n<p>*   <strong><code>xml.etree.ElementTree<\/code><\/strong> ile, XML a\u011fac\u0131n\u0131 manuel olarak gezerek ve \u00f6zyinelemeli bir fonksiyon yazarak XML&#8217;i s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015ft\u00fcrebilirsiniz. Bu y\u00f6ntem, d\u00f6n\u00fc\u015f\u00fcm s\u00fcreci \u00fczerinde tam kontrol sa\u011flar ve \u00e7ok b\u00fcy\u00fck XML dosyalar\u0131 i\u00e7in <code>iterparse<\/code> ile bellek verimlili\u011fi sunar.<br \/>\n*   <strong><code>xmltodict<\/code><\/strong> ise, tek bir fonksiyon \u00e7a\u011fr\u0131s\u0131yla XML&#8217;i Python s\u00f6zl\u00fc\u011f\u00fcne d\u00f6n\u00fc\u015ft\u00fcrerek geli\u015ftirme s\u00fcrecini \u00f6nemli \u00f6l\u00e7\u00fcde h\u0131zland\u0131r\u0131r. \u00d6zniteliklerin, metin i\u00e7eri\u011finin ve listelerin otomatik olarak i\u015flenmesi gibi kolayl\u0131klar sunar ve <code>postprocessor<\/code> gibi se\u00e7eneklerle \u00f6zelle\u015ftirilebilir.<\/p>\n<p>XML&#8217;den s\u00f6zl\u00fc\u011fe d\u00f6n\u00fc\u015f\u00fcm\u00fcn ard\u0131ndan, Python&#8217;\u0131n yerle\u015fik <code>json<\/code> mod\u00fcl\u00fc (<code>json.dumps()<\/code>) ile bu s\u00f6zl\u00fc\u011f\u00fc kolayca JSON format\u0131na \u00e7evirebilirsiniz. D\u00f6n\u00fc\u015f\u00fcm s\u0131ras\u0131nda veri tipi \u00e7\u0131kar\u0131m\u0131, bo\u015f elementlerin ele al\u0131n\u0131\u015f\u0131 ve hata y\u00f6netimi gibi konulara dikkat etmek, g\u00fcvenilir ve beklenen \u00e7\u0131kt\u0131y\u0131 alman\u0131z\u0131 sa\u011flar.<\/p>\n<p>Hangi y\u00f6ntemin se\u00e7ilece\u011fi, projenin \u00f6zel gereksinimlerine, performans beklentilerine ve geli\u015ftiricinin tercihine ba\u011fl\u0131d\u0131r. H\u0131zl\u0131 ve kolay d\u00f6n\u00fc\u015f\u00fcmler i\u00e7in <code>xmltodict<\/code> genellikle en iyi se\u00e7enektir. Ancak, performans kritik senaryolarda veya karma\u015f\u0131k XML yap\u0131lar\u0131 \u00fczerinde ince taneli kontrol gerekti\u011finde <code>xml.etree.ElementTree<\/code> daha uygun olabilir. Her iki durumda da Python&#8217;\u0131n zengin ekosistemi, veri entegrasyonu ve d\u00f6n\u00fc\u015f\u00fcm\u00fc g\u00f6revlerini etkin bir \u015fekilde yerine getirmenizi sa\u011flar. Modern uygulamalar\u0131n \u00e7o\u011fu JSON&#8217;\u0131 tercih etse de, XML&#8217;in hala bir\u00e7ok alanda kullan\u0131ld\u0131\u011f\u0131 d\u00fc\u015f\u00fcn\u00fcld\u00fc\u011f\u00fcnde, bu d\u00f6n\u00fc\u015f\u00fcm yetenekleri Python geli\u015ftiricileri i\u00e7in vazge\u00e7ilmezdir.<\/body><\/p>\n","protected":false},"excerpt":{"rendered":"Python ile XML&#8217;den JSON&#8217;a ve XML&#8217;den Dict&#8217;e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber\nGiri\u015f: Veri De\u011fi\u015fiminde XML ve JSON&#8217;\u0131n Rol\u00fc\nG\u00fcn\u00fcm\u00fcz\u00fcn ba\u011flant","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[1403],"tags":[],"class_list":{"0":"post-33798","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-python","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python ile XML&#039;den JSON&#039;a ve XML&#039;den Dict&#039;e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python ile XML&#039;den JSON&#039;a ve XML&#039;den Dict&#039;e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber\" \/>\n<meta property=\"og:description\" content=\"Python ile XML&#039;den JSON&#039;a ve XML&#039;den Dict&#039;e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber Giri\u015f: Veri De\u011fi\u015fiminde XML ve JSON&#039;\u0131n Rol\u00fc G\u00fcn\u00fcm\u00fcz\u00fcn ba\u011flant\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2025-11-07T03:41:01+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"23 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"Python ile XML&#8217;den JSON&#8217;a ve XML&#8217;den Dict&#8217;e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber\",\"datePublished\":\"2025-11-07T03:41:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/\"},\"wordCount\":3188,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"articleSection\":[\"Python\"],\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/#respond\"]}],\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/\",\"name\":\"Python ile XML'den JSON'a ve XML'den Dict'e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2025-11-07T03:41:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python ile XML&#8217;den JSON&#8217;a ve XML&#8217;den Dict&#8217;e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python ile XML'den JSON'a ve XML'den Dict'e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/","og_locale":"tr_TR","og_type":"article","og_title":"Python ile XML'den JSON'a ve XML'den Dict'e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber","og_description":"Python ile XML'den JSON'a ve XML'den Dict'e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber Giri\u015f: Veri De\u011fi\u015fiminde XML ve JSON'\u0131n Rol\u00fc G\u00fcn\u00fcm\u00fcz\u00fcn ba\u011flant","og_url":"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2025-11-07T03:41:01+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"23 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"Python ile XML&#8217;den JSON&#8217;a ve XML&#8217;den Dict&#8217;e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber","datePublished":"2025-11-07T03:41:01+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/"},"wordCount":3188,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"articleSection":["Python"],"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/#respond"]}],"copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/","url":"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/","name":"Python ile XML'den JSON'a ve XML'den Dict'e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2025-11-07T03:41:01+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/python-ile-xmlden-jsona-ve-xmlden-dicte-donusum-kapsamli-bir-rehber\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python ile XML&#8217;den JSON&#8217;a ve XML&#8217;den Dict&#8217;e D\u00f6n\u00fc\u015f\u00fcm: Kapsaml\u0131 Bir Rehber"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/33798","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=33798"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/33798\/revisions"}],"predecessor-version":[{"id":33799,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/33798\/revisions\/33799"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=33798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=33798"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=33798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}