Skip to content

Instantly share code, notes, and snippets.

@jessepeterson
Created October 19, 2022 20:45
Show Gist options
  • Save jessepeterson/b5fe3fb77c77266a647c889c84a103d8 to your computer and use it in GitHub Desktop.
Save jessepeterson/b5fe3fb77c77266a647c889c84a103d8 to your computer and use it in GitHub Desktop.
Invalid XML for plist ... successful?
package main
import (
"fmt"
"log"
"github.com/groob/plist"
)
const cmdPlist = `C "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Command</key>
<dict>
<key>RequestType</key>
<string>DeviceInformation</string>
</dict>
<key>CommandUUID</key>
<string>a84bb3f9-c3a0-47e2-af01-7c053abedba6</string>
</dict>
</plist>`
type Cmd struct {
Command struct {
RequestType string
}
CommandUUID string
}
func main() {
c := new(Cmd)
if err := plist.Unmarshal([]byte(cmdPlist), c); err == nil {
fmt.Println(c.CommandUUID, c.Command.RequestType)
} else {
log.Fatal(err)
}
}
@jessepeterson
Copy link
Author

Output of running this:

a84bb3f9-c3a0-47e2-af01-7c053abedba6 DeviceInformation

I.e. successfully parses it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment