The Easiest Way to Parse XML with JavaScript

Поделиться
HTML-код
  • Опубликовано: 24 янв 2023
  • In this video, I'll show you how easy it is to parse XML strings using JavaScript - no libraries or frameworks are required to do this 🙂
    Towards the end I'll also show a Fetch example where an XML document is retrieved from a file and then parsed to access the data within it.
    For your reference, check this out:
    developer.mozilla.org/en-US/d...
    🏫 My Udemy Courses - www.udemy.com/user/domenic-co...
    🎨 Download my VS Code theme - marketplace.visualstudio.com/...
    💜 Join my Discord Server - / discord
    🐦 Find me on Twitter - / dcodeyt
    💸 Support me on Patreon - / dcode
    📰 Follow me on DEV Community - dev.to/dcodeyt
    📹 Join this channel to get access to perks - / @dcode-software
    If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
    #dcode #javascript

Комментарии • 33

  • @ahmedAltariqi
    @ahmedAltariqi Год назад

    You're awesome!
    Thank you so much for this great tutorial -- because of you now I don't have to ttml-to-json python package, and my code runs way much faster!

  • @crownkiwifactoryNZ
    @crownkiwifactoryNZ 8 месяцев назад

    Thank you for the tutorial, it helps me a lot at work. ❤

  • @ubermensch-mne
    @ubermensch-mne Год назад

    Useful video, thanks.

  • @arnosolo2008
    @arnosolo2008 9 месяцев назад

    Thank you so much! 😸

  • @sondrepedersen7919
    @sondrepedersen7919 Год назад +4

    Wow, exactly what I needed! I was about to go crazy with some regex, but I think you just saved me a lot of pain

    • @dcode-software
      @dcode-software  Год назад

      Absolutely! I'm glad to hear that I prevented you from going down that path (it would have been a pain)

  • @thierrysandre440
    @thierrysandre440 Год назад

    Excellent !👍

  • @mariumbegum7325
    @mariumbegum7325 Год назад

    great video!

  • @alvarobyrne
    @alvarobyrne Год назад

    Humble and humbling DOMParser, nice, didn't know,

  • @cutefunnypets3164
    @cutefunnypets3164 Год назад

    keep up the awesome work bro!💪

  • @ivanetinajero
    @ivanetinajero Год назад +2

    Great content. How can I ask If an element exists inside the XML document? Thanks for this great an easy tutorial.

  • @kipo44
    @kipo44 Год назад

    thanks, bro

  • @SuviTuuliAllan
    @SuviTuuliAllan Год назад

    Is it true that text/xml is parsed as US-ASCII while application/xml is parsed as UTF-8?

  • @zegarek840525
    @zegarek840525 Год назад

    What about big file?? Is there in 2023 native SAX parser??

  • @Dhiraj_Chaudhari
    @Dhiraj_Chaudhari 6 месяцев назад

    Can you please tell how to parse any content data from dynamic html file

  • @mohamedsimo6021
    @mohamedsimo6021 Год назад

    Can you please do a video about how to create like vuejs library I mean reactivity etc I watched the your spa video and I like it .

  • @xawoo6655
    @xawoo6655 7 месяцев назад

    🦩 Hello everyone!
    🟢 00:00 - introduction
    🟢 01:00 - handle xml from string
    🟢 01:40 - use of DOM parser
    🟢 03:24 - element navigation
    🟢 05:20 - handle xml from fetch request

  • @khamzateedira9021
    @khamzateedira9021 Год назад

    Can you do somme video about react

  • @Konslufius
    @Konslufius Год назад +2

    Where were you like 2 months ago??

    • @dcode-software
      @dcode-software  Год назад +1

      Were you looking to parse XML 2 months ago? 😆

  • @aleksandrkobelev8868
    @aleksandrkobelev8868 11 месяцев назад

    If you have error put in your xml

  • @vijayjeee8806
    @vijayjeee8806 Год назад

  • @tamerlone5094
    @tamerlone5094 Год назад

    When I paste in the xml as he has it (1st part of the video), the editor throws an error and doesn't like the XML pasted. Anyone else have this problem?

    • @danielcook237
      @danielcook237 6 месяцев назад

      Yeah I did, I was using ' instead of ` .

  • @erturkyorulmaz7376
    @erturkyorulmaz7376 Год назад

    Verry helpful channel!.. 👏 Do you have a link for codes? Or shall I write it! :) 🌹

    • @dcode-software
      @dcode-software  Год назад +1

      Hey, thank you! I assume you have some XML somewhere else but if not there's plenty of XML examples online - any of them should work 😎👍

    • @erturkyorulmaz7376
      @erturkyorulmaz7376 Год назад

      @@dcode-software Hi! I mean the JS code you write in your videos. But, no prblem I can write again. Thank you for your kindness and videos that help us. 👋

  • @christianromero7982
    @christianromero7982 Год назад

    i can not split my string literal across multiple lines

  • @madalabhavyasri-nr6pr
    @madalabhavyasri-nr6pr Год назад

    How to convert this XML string to json??

    • @weixiaolisa
      @weixiaolisa 11 месяцев назад

      function xml2json(xml) {
      if (xml.children.length === 0)
      return xml.textContent.trim()
      const obj = {}
      for (let child of xml.children) {
      const name = child.nodeName
      if (obj[name] === undefined)
      obj[name] = xml2json(child)
      else {
      if (!Array.isArray(obj[name]))
      obj[name] = [obj[name]]
      obj[name].push(xml2json(child))
      }
      }
      return obj
      }

  • @fgscaglioni
    @fgscaglioni 10 месяцев назад

    Excelente!! Me ajudou muito!