Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String from XML?
#24
Kevin, how can the code you last posted be modified to only show the time and uri for the line that is current? Thanks

Something like this but I know you will show best practice.
 
Code:
Copy      Help
Macro [b]Macro74[/b] [help1][/help1]
[code]str s1 s2 final
typelib WinHttp {662901FC-6951-4854-9EB2-D9A2570F2B2E} 5.1
WinHttp.WinHttpRequest h._create
WinHttp.WinHttpRequest i._create

// First Request
h.Open("GET" "http://127.0.0.1:8080/requests/playlist.xml")
h.setRequestHeader("content-type", "application/xml")
str enc.encrypt(4 ":vlcremote") ;; replace with your password if needed
h.SetRequestHeader("Authorization", F"Basic {enc}")
h.Send()
err out _error.description; ret

if h.Status=200
,IXml x._create
,x.FromString(h.ResponseText)
,ARRAY(IXmlNode) a
,x.Path(".//leaf" a)
,for _i 0 a.len
,,IXmlNode attr attr2 attr3; attr=a[_i].Attribute("uri")
,,attr2=a[_i].Attribute("current")
,,if(attr2)
,,,s2=attr.Value
,,,s2.escape(8)
,,,s2.replacerx("file:///" "")
,,,
,,,// Second Request for current playback time
,,,i.Open("GET" "http://127.0.0.1:8080/requests/status.xml")
,,,i.setRequestHeader("content-type", "application/xml")
,,,i.SetRequestHeader("Authorization", F"Basic {enc}")
,,,i.Send()
,,,err out _error.description; ret
,,,if i.Status=200
,,,,IXml x1._create
,,,,x1.FromString(i.ResponseText)
,,,,attr3=x1.Path("root/time")
,,,,if(attr3)
,,,,,s1 = attr3.Value
,,,final = F"{s1},{s2}"
,,,break ;; stop after finding current item
out
out final
[/code]


Messages In This Thread
String from XML? - by pctechtv - 03-04-2022, 12:14 PM
RE: String from XML? - by Kevin - 03-04-2022, 04:33 PM
RE: String from XML? - by pctechtv - 03-06-2022, 05:51 AM
RE: String from XML? - by pctechtv - 03-06-2022, 09:34 AM
RE: String from XML? - by Kevin - 03-06-2022, 02:18 PM
RE: String from XML? - by pctechtv - 03-06-2022, 09:10 PM
RE: String from XML? - by Kevin - 03-09-2022, 02:57 PM
RE: String from XML? - by pctechtv - 03-12-2022, 02:41 PM
RE: String from XML? - by pctechtv - 05-23-2023, 04:29 AM
RE: String from XML? - by pctechtv - 05-23-2023, 12:51 PM
RE: String from XML? - by Kevin - 05-23-2023, 05:34 PM
RE: String from XML? - by pctechtv - 05-25-2023, 03:54 PM
RE: String from XML? - by Kevin - 05-27-2023, 12:08 PM
RE: String from XML? - by pctechtv - 06-07-2023, 04:22 PM
RE: String from XML? - by pctechtv - 06-10-2025, 12:36 AM
RE: String from XML? - by Gintaras - 06-10-2025, 07:32 AM
RE: String from XML? - by pctechtv - 06-10-2025, 07:20 PM
RE: String from XML? - by pctechtv - 06-11-2025, 02:30 AM
RE: String from XML? - by Kevin - 06-11-2025, 02:45 AM
RE: String from XML? - by pctechtv - 06-11-2025, 11:41 AM
RE: String from XML? - by Kevin - 06-11-2025, 12:09 PM
RE: String from XML? - by Kevin - 06-11-2025, 04:23 PM
RE: String from XML? - by pctechtv - 06-11-2025, 04:50 PM
RE: String from XML? - by pctechtv - 06-12-2025, 08:33 PM
RE: String from XML? - by Kevin - 06-17-2025, 02:53 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)