Results 1 to 5 of 5

Thread: Upgraded XPath/XML

  1. #1
    Junior Member
    Join Date
    Aug 2017
    Posts
    6

    Default Upgraded XPath/XML

    I wanted to use XPath in ash, but the current xpath function only partially implemented xpath, so I wrote added in a new xpath function, as well as some other xml stuff.

    Ash things added:
    type: xmlnode - A type to hold an xml node.
    function: to_xml(string xml, boolean cleanHtml) - Turns a string of xml in an xml document, returns an xmlnode which is a reference to the root element. If cleanHtml is true, it runs the string throught the htmlCleaner class.
    function: to_xml(string xml) - Same as above, doesn't html clean the xml.
    function: xpath(xmlnode node, string expression) - Runs an xpath expression on the xmlnode node/document that is passed in.
    function: to_string(xmlnode node) - Returns a string of the xml of node and its children

    xmlnode members:
    to_string - Same as to_string(xmlnode node).
    name - Returns the xmlnode tag name.
    inner - Concatenates a to_string of all children of the xmlnode and returns it. (Not sure if this really has much use besides getting the value of an attribute or maybe for a node that only has text inside it.)

    On the internal side I also modified the LibraryFunction class. I added a 4th parameter, so that the ash function name and java function name in the RuntimeLibrary class don't need to be the same. This allows better overloading of ash functions. There were issues because because all parameter types of the RuntimeLibrary functions are Value, which means an ash function couldn't have any overloads that had the same number of arguments. I also added/kept a 3 parameter constructor for the class, for compatibility and.. brevity? less wordlyness? (there's a coding word I'm thinking of but I can't remember it right now), which chains to the 4 parameter constructor.

    Anyways, let me know what you guys think. It hasn't been thoroughly tested so there could be errors, but everything seemed to work for me.
    Attached Files

  2. #2
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,620

    Default

    I'll look at this, by and by, but on forum conventions:

    If you want a feature - even if you supply code - mark it "Feature". If and when we submit code to KoLmafia - perhaps taking/adapting your supplied code - then we mark it Implemented. You do not mark it "Feature - Implemented" yourself, just because you supplied code, because the onlooker expects that means the code exists in released KoLmafia code.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  3. #3
    Junior Member
    Join Date
    Aug 2017
    Posts
    6

    Default

    My apologies, I wasn't sure which tag to use.

  4. #4
    Junior Member
    Join Date
    Aug 2017
    Posts
    6

    Default

    Any progress/thoughts on this?

  5. #5
    Senior Member
    Join Date
    Apr 2018
    Posts
    250

    Default

    Id really appreciate standards-compliant XPath support.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •