Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

XPath or Java for filtering - what is faster?

  • 10-03-2016 3:52pm
    #1
    Closed Accounts Posts: 6,075 ✭✭✭


    I have an XML file that I am parsing using XPath. In the document, there is a list of elements. My existing code parses the xml into Java objects and processes them.

    My new requirement is to not take all elements in the list - if the ID of the element is A or B, ignore it, but I want to keep C, D and E.

    My question is, what is fastest:
    1. Parse and save the entire list into Java objects, then filter out A and B
    2. Use XPath to exclude A and B.


Comments

  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,242 Mod ✭✭✭✭L.Jenkins


    Would it not be easier to keep your code as is and manipulate the XPath file as needed, should the XML file change?


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    Itzy wrote: »
    Would it not be easier to keep your code as is and manipulate the XPath file as needed, should the XML file change?

    So filter out using Xpath? Like such?


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,242 Mod ✭✭✭✭L.Jenkins


    I'm no expert, but I'm wondering is it easier that way.


  • Closed Accounts Posts: 8,015 ✭✭✭CreepingDeath


    My question is, what is fastest:
    1. Parse and save the entire list into Java objects, then filter out A and B
    2. Use XPath to exclude A and B.

    There's also an option 3, to use XSLT stylesheets to transform the original XML into one specific for your code, performing any business filtering of elements in the stylesheet. Especially if you are not in control of the structure of the XML, eg. it's from a client/third party.


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    There's also an option 3, to use XSLT stylesheets to transform the original XML into one specific for your code, performing any business filtering of elements in the stylesheet. Especially if you are not in control of the structure of the XML, eg. it's from a client/third party.

    I can't use anything other than XPath and Java. The existing code uses those to parse the existing XML. My job is to filter out one part of it. I will not be re-writing the existing code.


  • Advertisement
  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,242 Mod ✭✭✭✭L.Jenkins


    I can't use anything other than XPath and Java. The existing code uses those to parse the existing XML. My job is to filter out one part of it. I will not be re-writing the existing code.

    Well it seems that your only option is to modify the XML document to ensure nothing in the original source code doesn't break.


Advertisement