logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
svetotehnik  
#1 Posted : Wednesday, November 3, 2021 11:21:00 PM(UTC)
svetotehnik

Rank: Member

Groups: Registered
Joined: 11/6/2020(UTC)
Posts: 21
Russian Federation
Location: Saint-Petersburg

Thanks: 6 times
Was thanked: 1 time(s) in 1 post(s)
I need to get timecode of input, this code works:

Code:
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)

dim time_position as string = (x.SelectSingleNode("//input[@number=1]/@position").Value)


but if I need to set number of active input it returns exception:

Code:
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)

dim active_input as string = (x.SelectSingleNode("//active").InnerText)
dim time_position as string = (x.SelectSingleNode("//input[@number=active_input]/@position").Value)


tried to change to integer, also doesnt work. when write to console input determinates correctly

thank you!
Papo  
#2 Posted : Thursday, November 4, 2021 10:40:16 AM(UTC)
Papo

Rank: Advanced Member

Groups: Registered
Joined: 6/16/2020(UTC)
Posts: 77
Peru

Thanks: 8 times
Was thanked: 2 time(s) in 2 post(s)
At first glance you can see that the xpath has a variable inside in this case active_input, you have to separate that variable from everything and or concatenate it.
translated from spanish with google
GregS  
#3 Posted : Thursday, November 4, 2021 11:29:43 AM(UTC)
GregS

Rank: Newbie

Groups: Registered
Joined: 10/20/2021(UTC)
Posts: 5
Canada
Location: Ontario

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
The reason your command is not working is because it is looking for an input numbered "time_position", rather than the value of time_position.

To do what you want try the following commands:
Quote:

dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)

dim time_position as string = (x.SelectSingleNode("//input[@number=1]/@position").Value)

dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)

dim position_query as string = "//input[@number=" + time_position + "]/@position"
dim time_position as string = (state.SelectSingleNode(position_query).Value)

dim position_query as string = "//input[@number=" + time_position + "]/@position"
creates the query string that contains the value of time_position e.g. "//input[@number=1]/@position".

dim time_position as string = (state.SelectSingleNode(position_query).Value)
performs the xml query to return the position value.
thanks 1 user thanked GregS for this useful post.
svetotehnik on 11/4/2021(UTC)
svetotehnik  
#4 Posted : Thursday, November 4, 2021 2:37:30 PM(UTC)
svetotehnik

Rank: Member

Groups: Registered
Joined: 11/6/2020(UTC)
Posts: 21
Russian Federation
Location: Saint-Petersburg

Thanks: 6 times
Was thanked: 1 time(s) in 1 post(s)
Originally Posted by: GregS Go to Quoted Post
The reason your command is not working is because it is looking for an input numbered "time_position", rather than the value of time_position


Thank you very much!

I still don't quite understand how it works, but it does)

Code:
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)

dim active_input as string = (x.SelectSingleNode("//active").InnerText)

dim xml2 as string = API.XML()
dim x2 as new system.xml.xmldocument
x2.loadxml(xml)

dim position_query as string = "//input[@number=" + active_input + "]/@position"
dim time_position as string = (x2.SelectSingleNode(position_query).Value)

doggy  
#5 Posted : Thursday, November 4, 2021 5:00:34 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,218
Belgium
Location: Belgium

Thanks: 291 times
Was thanked: 955 time(s) in 790 post(s)
Code:
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)

dim active_input as string = (x.SelectSingleNode("//active").InnerText)
dim time_position as string = (x.SelectSingleNode("//input[@number=" + active_input + "]/@position").Value)

Console.writeline(time_position )
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.