Handling xml getEnclosingValue()

Discuss issues related to PS3 Media Server development (only for programmers)

Handling xml getEnclosingValue()

Postby emveepee » Sun Feb 06, 2011 1:17 am

I tried to open this post viewtopic.php?f=15&t=9746 as a developer problem but it was moved. Anyway here is a potential solution should someone like to run with it, I have never used java before so there probably is a better solution.
Code: Select all
   private String getEnclosingValue(String content, String leftTag, String rightTag) {
      String result = null;
      int leftTagPos = content.indexOf(leftTag);
      int rightTagPos =  content.indexOf(rightTag, leftTagPos+1);
      if (leftTagPos > -1 && rightTagPos > leftTagPos) {
                        if (leftTag.startsWith("<") ){
                            int mybrace= content.lastIndexOf(">",rightTagPos);
                            if (mybrace > leftTagPos) {
                 result = content.substring(mybrace+1, rightTagPos);
                            }
                        } else {
             result = content.substring(leftTagPos + leftTag.length(), rightTagPos);
                        }
      }
      return result;
   }


Martin
emveepee
 
Posts: 18
Joined: Fri Feb 04, 2011 8:35 pm

Re: Handling xml getEnclosingValue()

Postby emveepee » Sun Feb 06, 2011 1:23 am

I also changed the calls to remove the ending >

objectID = getEnclosingValue(content, "<ObjectID", "</ObjectID>");

This probably could all be done in the function.

Martin
emveepee
 
Posts: 18
Joined: Fri Feb 04, 2011 8:35 pm

Re: Handling xml getEnclosingValue()

Postby meskibob » Sun Feb 06, 2011 1:52 am

I moved the thread as that is appropriate section of the forum for the generic renderer issue as was stated in the first post (other clients have had issues initially browsing the directory due to improper conf files). Thanks to your additional investigations, it now makes sense to move it back, except this thread already exists.
Sorry for the confusion.

Hopefully one of the devs can take a look at your code and implement a fix in the trunk.
I provide NO application support via PM or email, so please post your question to the forum per the Forum Rules.
meskibob
Moderator
 
Posts: 4763
Joined: Mon Jan 19, 2009 4:11 pm


Return to Developers

Who is online

Users browsing this forum: No registered users and 2 guests