forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


XML

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
gerrit
Newbie


Joined: 14 May 2004
Posts: 24

PostPosted: Thu May 20, 2004 2:42 pm    Post subject: XML Reply with quote

Has someone some experience in parsing XML files? Is there may a function to Parse them?
I don't kenw how to do it, because I dont think that's possible with the parse Command.

;)) Thanks,
Gerrit

_________________
___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Thu May 20, 2004 6:49 pm    Post subject: Reply with quote

Welcome to the forums, Gerrit! Hi

VDS doesn't include an XML parsing component, but it can be done. What
kind of XML file are you planning to parse? Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
gerrit
Newbie


Joined: 14 May 2004
Posts: 24

PostPosted: Thu May 20, 2004 10:40 pm    Post subject: My project... ;) Reply with quote

Hi FreezingFire, thanks for the Welcome... ;)

Well I think to go a bit more than this..
I wrote a small Programm witsh will write Combustion Workspaces.
Combustion is a Compositing tool like Photoshop (i.e. After effects) just for working on film and Video's. I'm Working since 12 Jears in this Job as (mostly) Demo artist.
The big Problem of all these Film Company's is that they are not communicating to another software, so I tried to learn C++ to just Mixx some Lists in a logical Position together. It was a desaster to do this in C++ .. Copycat.. Thousend of classes and this bloody ";" witsh I forgot every line....
Than I found (was wery hard to find) VDS, and like every other scripting laguage I was wery fast to Produce something useful.
After a Half jear Work I got this damm Workspace done without any kind of development or description on their company side. (kind of reverse engeneering..)

Okay now to come to the Point..
I can now Write with my tool these Workspaces, but some of the NLE (Non Linear Editing) Company's write just XML Files of any nessesary Parameters in a timeline.
My Problem is that I can just write this file by loading a List (Textfile) and Processing the Data.
When these Companys are not writing exactly my Textfile than I cant Process this file.
Some of these Company's only support XML Output, and they don't want to spepnd any Programmer to make my tool Working. They all Want it, also all the Customers who bought Combustion, but they don't wanna spend some time to Make this working.
I'm not doing this to make the big mony. I'm doing this because I'm also a customer, and it pisses me off that some BIG Fat Company's earning so mutsh mony while some small Company's have a very good tecnoligy or idea behind it, and U can't brig the result into another software. Other words I want to blast off some big comp's with it.

What I want is to may scan eatsh line in a XML file. I don't knew exactly the XML Description jet.
<layer foo>
<Filename fooooo.foo 12 50 13 12>
<Scale Layer foo 50 50>
</layer foo>

What I need to do is to load them into a list... already done it with Html Files. And then to find a string <Layer XXXXXX> If I found this string I will scan eatsh other line for the Param's until </Layer XXXXXX>
For this I need just the command to do this... How it works I will figure out myself... to save some time here.. ;)

I think that's all I need to do, because when I knew how to seperate the XXXXX than I can Process the Data by the same.
I realy did'nt find a command/func to search in a line of a list for a specific string and the next following chr's until the > Or Space put in Variable Foo....


I hope that you can undersand... my bloody english i meen.... ;)))

Thanks a Lot... ;)
Gerrit

_________________
___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________
Back to top
View user's profile Send private message Visit poster's website
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Fri May 21, 2004 7:33 am    Post subject: Reply with quote

There isn't a command to do this. You would have to write some code.

I would build some parsing routines with code like:

Code:
# %L is a line of text read from a list
%P = @pos(<Layer,%L)
repeat
  %P = @succ(%P)
  %S = @substr(%L,%P)
until @equal(%S," ")@equal(%S,">")

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
gerrit
Newbie


Joined: 14 May 2004
Posts: 24

PostPosted: Fri May 21, 2004 1:04 pm    Post subject: Reply with quote

Thanks jules.. Wink

That was exactly what I needed...

Made a function for it, but still have Problems with characters like " " and "="??

(Missing Parameter(s) to command)
Do I need to use the @Chr() Function for these sign's?

Function is:

Code:

#define function,xmlparse
:xmlparse
  %%StrgToParse = %1
  %%SearchStrg_length = @sum(@LEN(%2),1)
  %%SearchStrg = %2
  %%StrgToParseStart = @pos(%%SearchStrg,%%StrgToParse)
   
rem ****  Parse End of Searched String  ****
  %%Pos = @pos(%%SearchStrg,%%StrgToParse)
        repeat
        %%Pos = @succ(%%Pos)
        %%Comp = @substr(%%StrgToParse,%%Pos)
        until @equal(%%Comp,%3)
        rem @equal(%%Comp," ")

rem **** Output of Searched String **** 
 %%StrgOutput_Length = @sum(%%pos,-1)
 %%OutputStrg = @substr(%%StrgToParse,@sum(%%StrgToParseStart,%%SearchStrg_length),%%StrgOutput_Length) 
 
rem  %%OutputStrg = @substr(%%StrgToParse,@sum(%%StrgToParseStart,%%SearchStrg_length),@sum(@sum(%%StrgToParseStart,%%SearchStrg_length),%%StrgOutput_Length)) 
       
 Exit %%OutputStrg
 




Funktion Call:


Code:

#include XMLParseString2
rem <Format Name="AVI" GUID="{56FF688E-738F-4d35-94C1-AFB579CC2164}" version="2.0" MediaType="VIDEO" StreamCount="1" Author="Somebody">
%%st = <Format Name="AVI" GUID="{56FF688E-738F-4d35-94C1-AFB579CC2164}" version="2.0" MediaType="VIDEO" StreamCount="1" Author="Somebody">
rem info <Format Name="AVI" GUID="{56FF688E-738F-4d35-94C1-AFB579CC2164}" version="2.0" MediaType="VIDEO" StreamCount="1" Author="Somebody">       
info @XMLParse(%%st,Format Name,"=")


Lovly.... Wink

Gerrit

_________________
___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________
Back to top
View user's profile Send private message Visit poster's website
gerrit
Newbie


Joined: 14 May 2004
Posts: 24

PostPosted: Sun May 23, 2004 1:48 pm    Post subject: ...???? ;( Reply with quote

Tried around a lot, but I can't get this Func working....

To Parse a XML File it's nessesary to search Chr's like "=" @Chr(32) and " " @Chr(61).
But my Func. is still telling me that he's missing a Parameter..?? No clue Confused Stupid Miserable

I tried now with...
Code:
@XMLParse(%%st,Format Name,@CHR(32))
@XMLParse(%%st,Format Name,@CHR(61))
@XMLParse(%%st,Format Name," ")
@XMLParse(%%st,Format Name,"=")


I think there must be something Basic wrong Embarassed
Still a beginner...


Pleeezzeee Master Worship

Gerrit

_________________
___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun May 23, 2004 5:23 pm    Post subject: Reply with quote

Did you create a user-defined function XMLParse? Smile
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Sun May 23, 2004 6:01 pm    Post subject: Reply with quote

I assume that you need to parse a value between two XML tags... am I right?
Well, I needed such a thing a while ago... I've posted the code below, you can have a look if it's of any use Wink

Code:

external string.dll
#define function, string

%%StartTag = <title>
%%EndTag = </title>
%%String = <title>Hello!</title>

info @trim(@string(GetAfter, @string(GetBefore, %%String, %%EndTag), %%StartTag))

This code requires string.dll to work.

EDIT: Oops.. uhm... I didn't saw that you needed to get the parameters of a xml tag. Perhaps this code still is of any use. I would recommend you to use the string.dll to do the string manipulating, it's much more faster then VDS itself.


Regards,
Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
gerrit
Newbie


Joined: 14 May 2004
Posts: 24

PostPosted: Mon May 24, 2004 10:05 am    Post subject: Reply with quote

Hi FreezingFire, Vic...

Jeeep, did this Func by myself... with a bit help from Jules.
With this I learned how to use the SubStr func.

I tried a bit mor, and figured out that my little Problem has nothing to do with the Func. It seem's that SubStr Function doesn't take any signs witsh are used by VDS itself "()=, ", eaven if they are defined with a @Chr() Func. <-- is this possible??
If yes, are all Func's limited to this?
Well my plan was to prvent external dll's first, and learn the basic language of VDS. But if this is a limitation, than there is no other way than to use a DLL.

The point is when I use myown Func, than I can tweek it as needed, and understand how the basic parsing of soem param's work.

The XML what I want to parse looks like this, and I think I need to parse in a more complex way than just <></>...
When I parsed everything, I need to find a way to put the colected data in a kind of order to put it into my other programm that he writes a CWS (Combustion Workspace)

May someone of the Worship Worship Worship have an Idea.. Idea Wink
But thanks Vic, I will Shocked into the DLL anyway... Very Happy

Code:

<?xml version="1.0"?>
<!DOCTYPE ConversionInfo SYSTEM "mediainfo.dtd" >
<ConversionInfo>
   <InputFile Name="E:\temp\Media_incite\tt.avi" StreamNumber="0" PrefFilter="RiffSrc" MediaType="VIDEO"/>
   <OutputFile Name="E:\temp\Media_incite\after_capturing.avi">
      <Format Name="AVI" GUID="{56FF688E-738F-4d35-94C1-AFB579CC2164}" version="2.0" MediaType="VIDEO" StreamCount="1" Author="Somebody">
         <Description>Some usefull information for end-user</Description>
         <CopyRight></CopyRight>
         <Title>Drama</Title>
         <MediaStream MediaType="VIDEO" Default="YES" StreamNumber="0">
            <Parameters><Parameter Name="FrameRate" Value="20.000000"/></Parameters><Compressor Name="Matrox MPEG2 I-frame" GUID="" fccHandler="mmes" fccCompression="">
                 <Parameters><Parameter Name="VideoCodecString" Value="766964736D6D65730F0000003421000000000000040000000000000000000000000000000000000000000000"/><Parameter Name="KeyFrame" Value="1"/></Parameters></Compressor>
         </MediaStream>
      </Format>
   </OutputFile>
</ConversionInfo>

_________________
___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Jun 04, 2004 7:47 pm    Post subject: Reply with quote

Welcome Gerrit,
I am not sure what your XMLParse is supposed to return but take a look at the changes I have made to it and tell me if this is close to what you want?

Code:
#define function,xmlparse
rem #include XMLParseString2
rem <Format Name="AVI" GUID="{56FF688E-738F-4d35-94C1-AFB579CC2164}" version="2.0" MediaType="VIDEO" StreamCount="1" Author="Somebody">
%%st = <Format Name=@CHR(34)AVI@CHR(34) GUID=@CHR(34){56FF688E-738F-4d35-94C1-AFB579CC2164}@CHR(34) version=@CHR(34)2.0@CHR(34) MediaType=@CHR(34)VIDEO@CHR(34) StreamCount=@CHR(34)1@CHR(34) Author=@CHR(34)Somebody@CHR(34)>
rem info <Format Name="AVI" GUID="{56FF688E-738F-4d35-94C1-AFB579CC2164}" version="2.0" MediaType="VIDEO" StreamCount="1" Author="Somebody">
info @XMLParse(%%st,Format Name,@chr(61))@CR()
exit
   
:xmlparse
  %%StrgToParse = %1
  %%SearchStrg_length = @sum(@LEN(%2),1)
  %%SearchStrg = %2
  %%StrgToParseStart = @pos(%%SearchStrg,%%StrgToParse)

  rem ****  Parse End of Searched String  ****
  %%Pos = @pos(%%SearchStrg,%%StrgToParse)
  repeat
    %%Comp = @substr(%%StrgToParse,%%Pos)
    %%Pos = @succ(%%Pos)     
  until @equal(%%Comp,%3)
 
  rem @equal(%%Comp," ")

  rem **** Output of Searched String ****
  %%StrgOutput_Length = %%pos
  %%OutputStrg = @substr(%%StrgToParse,%%StrgOutput_Length,@len(%%StrgToParse))
  rem %%OutputStrg = @substr(%%StrgToParse,@sum(%%StrgToParseStart,%%SearchStrg_length),%%StrgOutput_Length)

  rem  %%OutputStrg = @substr(%%StrgToParse,@sum(%%StrgToParseStart,%%SearchStrg_length),@sum(@sum(%%StrgToParseStart,%%SearchStrg_length),%%StrgOutput_Length))

  Exit %%OutputStrg


If the string your tring to parse is assigned to a variable in VDS you need to either use double quotes like so %%st = ""MyString"" or use @chr(34) like so %%st = @chr(34)MyString@chr(34).... If you are reading from a file I don't think you have to worry about changing it. Like I said I am not sure what your function is supposed to return. Let me know and I will modify it for you if you need me to.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Jun 04, 2004 9:56 pm    Post subject: Reply with quote

Gerrit,
I thought about this some more and here ya go... I think you should be able to add features to this but this is the basics. I am sure it can be optimised more but you should be able to do simple XML/HTML parsing with this script. About the only thing it may have trouble with is the DOCTYPE tag and you will have to use an external loop to get tags that are repeated in the XML??? Still needs more work but have fun it's a start Wink





Code:
#define function,xmlparse
rem #include XMLParseString2
# Create a VDS string list
List create,1
# Load the sample XML/HTML into the string list
List loadtext,1,
"<?xml version="1.0"?>
"<!DOCTYPE ConversionInfo SYSTEM "mediainfo.dtd" >
"<ConversionInfo>
"   <InputFile Name="E:\temp\Media_incite\tt.avi" StreamNumber="0" PrefFilter="RiffSrc" MediaType="VIDEO"/>
"   <OutputFile Name="E:\temp\Media_incite\after_capturing.avi">
"      <Format Name="AVI" GUID="{56FF688E-738F-4d35-94C1-AFB579CC2164}" version="2.0" MediaType="VIDEO" StreamCount="1" Author="Somebody">
"         <Description>Some usefull information for end-user</Description>
"         <CopyRight></CopyRight>
"         <Title>Drama</Title>
"         <MediaStream MediaType="VIDEO" Default="YES" StreamNumber="0">
"            <Parameters>
"              <Parameter Name="FrameRate" Value="20.000000"/>
"            </Parameters>
"            <Compressor Name="Matrox MPEG2 I-frame" GUID="" fccHandler="mmes" fccCompression="">
"              <Parameters>
"                <Parameter Name="VideoCodecString" Value="766964736D6D65730F0000003421000000000000040000000000000000000000000000000000000000000000"/>
"                <Parameter Name="KeyFrame" Value="1"/>
"               </Parameters>
"             </Compressor>
"         </MediaStream>
"      </Format>
"   </OutputFile>
"</ConversionInfo>
# Save the contents of the string list into a VDS variable
%%st = @Text(1)
# Call our XMLparse function
# This function is just for simple XML/HTML queries it is not a full inplementation of XML parsing
# it returns fragments of XML/HTML or values to Attributes.
# You have to know the tag/Attribute names and the level that the tags/attributes are at to use this function in other words it's XPath as
# described by Micro$oft's XML parser.  This function does not use
# Micro$ofts XML parser but it does use a similar approach to parsing XML.
# Also Note: Whitespace is ignored but left intact so if your
#    XML/HTML has tabs or spaces those are left in the return value.
# Syntax:
# %A = @XMLParse(<XML/HTML to Parse>,<TagPath\NextTagLevel\...[Optional Attribute]>)

info @XMLParse(%%st,ConversionInfo\OutputFile\Format\MediaStream\Compressor\Parameters\Parameter[Value])@CR()
exit
   
:xmlparse
  # Initialize our variables
  %%StrgToParse = %1
  %%SearchStrg = %2
  # Save the current field seperator so we can return it for later use if needed.
  %%OldSep = @fsep()
  # Parse the XML/HTML Path if there is one looking for the last tag in the path consuming the XML/HTML and Search Path as it loops.
  if @Greater(@Pos(\,%%SearchStrg),0)
    Option FieldSep,\   
    Repeat
      PARSE "%%level",%%SearchStrg
      if @Greater(@len(%%level),1)
        if @UnEqual(@len(%%level),@len(%%SearchStrg))
          %%SearchStrg = @SubStr(%%SearchStrg,@sum(@len(%%level),2),@len(%%SearchStrg))
          %%Pos1 = @Pos(%%level,%%StrgToParse)
          %%StrgToParse = @SubStr(%%StrgToParse,%%Pos1,@len(%%StrgToParse))
        end
      End     
    Until @Equal(@len(%%level),@len(%%SearchStrg))
  End
  # We found the tag or tags we want to return so check if the user wants an attribute's value
  # or the whole tag...
  If @Greater(@Pos([,%%SearchStrg),0)
    Option FieldSep,[
    PARSE "%%TagName;%%AttrName",%%SearchStrg
    %%StrgToParse = @SubStr(%%StrgToParse,@Pos(%%TagName,%%StrgToParse),@len(%%StrgToParse))
    %%AttrName = @SubStr(%%AttrName,1,@pred(@len(%%AttrName)))
    %%Pos1 = @Pos(%%AttrName,%%StrgToParse)
    %%Attr = @SubStr(%%StrgToParse,%%Pos1,@len(%%StrgToParse))
    %%Pos1 = 1
    %%Pos2 = @pred(@Pos(>,%%Attr))
    %%Attr = @SubStr(%%Attr,1,%%Pos2)
    %%Pos1 = @Succ(@Pos(=,%%Attr))
    %%AttrVal = @SubStr(%%Attr,%%Pos1,@len(%%Attr))
    %%Pos2 = @Pos(@chr(34),%%Attr)
    %%Pos2 = @Diff(@len(%%AttrVal),%%Pos2)
    Option FieldSep,@chr(34)
    Parse "%%Val;%%Other",%%AttrVal
    %%AttrVal = %%Val
    Option FieldSep,%%OldSep
    %%OutputStrg = %%AttrVal
   
  Else
    %%Pos1 = @Succ(@Pos(<%%SearchStrg,%%StrgToParse))
    if @Greater(%%Pos1,0)
     
      if @Greater(@Pos(</%%SearchStrg>,%%StrgToParse),0)
        %%Pos2 = @Sum(@Pos(</%%SearchStrg>,%%StrgToParse),@len(</%%SearchStrg>))
      elsif @Greater(@Pos(/>,%%StrgToParse),0)
        %%Pos2 = @Sum(@Pos(/>,%%StrgToParse),@len(/>))
      end
      %%OutputStrg = <@SubStr(%%StrgToParse,%%Pos1,%%Pos2)
    end   
  End
  # Set our field seperator to it's original character.
  Option FieldSep,%%OldSep
Exit %%OutputStrg


Oops found a problem so I made a change. This is now a newer version. Ok I have added a few comments about what this function does and how to use it. Naturally this is only a simple parsing routine and is not a full implementation of XML parsing.

_________________
Home of

Give VDS a new purpose!


Last edited by vdsalchemist on Mon Jun 07, 2004 3:06 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
gerrit
Newbie


Joined: 14 May 2004
Posts: 24

PostPosted: Sat Jun 05, 2004 3:03 am    Post subject: WOW... Reply with quote

Wink Thanks...
I need a while to understand what exactly you did there..

but Thanks a lot...


gerrit Laughing

_________________
___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group