Javascript XML parsing


    Nov 08 2005 | 8:58 pm
    Hi - I'm new to the list and a month into Max.
    I tried instantiating an XML parser in Javascript, in Max/MSP, and couldn't
    find one. This seems unfortunate. Am I missing something? Is there one
    included? ( I tried DOMParser and searched for sample code )
    I finally used a parser built out of regular expressions - which works I
    guess. Though, it's not super clean.
    I tried using [ detox ] and the tap parser, though they didn't load the file
    contents into a DOM tree like structure I'm familiar with.
    Thanks for any thoughts.
    Jason Harlan
    Visiting Researcher - USC Interactive Media Division

    • Nov 08 2005 | 9:19 pm
      The Document Object Model and JavaScript are separate entities.
      They only happen to meet in your web browser.
      You could acces the DOM without JavaScript, for example with XSLT.
      And you can do things in JavaScript without the DOM.
      Also known as Core JavaScript, which is what Max has adopted.
      HtH
      -jennek
    • Nov 08 2005 | 9:30 pm
      That's clear - thanks.
    • Nov 08 2005 | 9:36 pm
      it was jason's question, so i'm glad it's clear to him and he got it
      but jennek, would you please give me a little more detail on how
      you'd do xml parsing just with javacript (or Core Javascript)?
      thanks,
      a
    • Nov 08 2005 | 9:49 pm
      On Nov 8, 2005, at 12:58 PM, Jason Harlan wrote:
      > I tried instantiating an XML parser in Javascript, in Max/MSP, and
      > couldn't find one. This seems unfortunate. Am I missing
      > something? Is there one included? ( I tried DOMParser and
      > searched for sample code )
      > I finally used a parser built out of regular expressions - which
      > works I guess. Though, it's not super clean.
      The following has both DOM and SAX style parsers written in Core JS.
      You would just use the MaxMSP file object to read in the file to a
      string which could be passed to these functions.
      Note that you can add classes and functions to be used by other
      scripts by placing the js file in the jsextensions folder, as is
      discussed in the following archive post, and demonstrated by the
      Jitter utility jsextensions installed with Jitter:
      Let us know if you encounter any problems.
      -Joshua
    • Nov 08 2005 | 9:50 pm
      Ali,
      this is what i used:
      and here's another - an elegant regular expression parse:
      though it lacks higher level method calls that the gazingus one has.
      Jason
    • Nov 09 2005 | 9:03 am
      Ali,
      I'd look for a public domain library capable of parsing XML into a DOM
      (and serializing the DOM back to XML), that could be called from the Max
      Core JavaScript implementation.
      And luckily enought I do not have to search the web for this anymore,
      as Joshua has already posted the URL where such a library can be found.
      On 8 Nov 2005, at 22:49, Joshua Kit Clayton wrote:
      This particular library is written in JavaScript, so it is easy to
      understand
      how you would use its classes in your javavascripts. As Joshua recalled,
      put it in the jsextensions folder
      The DOM is a pretty large animal and a full XPath implementation is
      absolutely
      nontrivial, so we are lucky that other people have created this
      library and share it with us.
      -jennek
    • Feb 20 2006 | 11:14 pm
    • Feb 25 2006 | 3:16 am
      Hi Javascript-Dev
      On Monday, this message was posted to the MaxMSP 2005 Mailing List archives, which automatically put it in the queue, as the mailing list archives are read-only, and no longer accepting entries. Sometimes, people will reply to an old thread and it will get updated in the list archives, and I'll move it out to the main MaxMSP list.
      In this case though, a post was made through the forum (note to users: please don't reply to old threads in the list archives!), but it also happened to be a thread which more appropriately goes into the Javascript forum. Therefore, I've moved this old max-msp list thread to this forum.
      List subscribers, I would encourage you to visit the thread and read over mzed's posting, and see if you can offer any help. Here's a direct link to this thread:
      Sorry for the length of this message, it's just a somewhat difficult situation to explain.
      cheers
      w
    • Feb 27 2013 | 10:35 am
      You can try SoftXPath ---> http://www.softxml.com/softxpathdemo.htm
      This is a small cross browser JavaScript library written for web developers who deals with XML parsing/querying on client side. You will be able to query complex XML documents using powerful Xpath expressions. Now you can focus on building effective Xpath expressions instead of wasting time on browser compatibility issues.
    • Mar 02 2015 | 3:27 pm