I’m finding it quite hard to find any really info on Xojo’s XML system and what I have found isn’t migrating that well to what I already know, so if all else fails … ask!
I need to be able to list the Object Camera names but also Parameters and return the values
This is the C# version, for collecting the camera names, its commented from when I did this version
The XML file is created by a 3D Render engine
[code] string path = iptPath + slashes + “temp.xml”;
System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
settings.ConformanceLevel = System.Xml.ConformanceLevel.Fragment;
using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(path))
{
while ((reader.Read()))
{
if ((reader.NodeType == System.Xml.XmlNodeType.Element))
{
if ((reader.Name == "Object"))
{
//Object Identifier="./Cameras/MyCamera" Label="Standard Camera" Name="MyCamera" Type="Camera"
string Identifier = reader.GetAttribute("Identifier");
//"./Cameras/MyCamera"
string Parameter = reader.GetAttribute("Parameter");
string Name = reader.GetAttribute("Name");
string Label = reader.GetAttribute("Label");
//"Standard Camera"
//"MyCamera"
string Type = reader.GetAttribute("Type");
//"Camera"
string Value2 = reader.GetAttribute("Value");
string wholeString = Name;
//Adding the string to cameralist
if ((wholeString.Length > 0) & Type == "Camera")
{
cameralist.Items.Add(wholeString);
}
} [/code]
dim f as folderItem=<folderitem to your xml file>
dim xDoc as new xmlDocument
try
xDoc.load(f)
catch
xDoc=nil //an error occurred
end try
dim names() as String
if xDoc<>nil then
dim xq as XmlNodeList
xq=xDoc.DocumentElement.Xql("Object/Object[@Type='Camera']")
dim i,n as integer
n=xq.Length-1
for i=0 to n
names.Append xq.Item(i).GetAttribute("Name")
next
end if
I’m still having little problem getting parameter settings,
going by what Antonio said, how do I get the value in parameter “Focal Length (mm)” or any other names?
with the previous example, you’ve got the camera name array with the list of nodes
for every node you can query (xql) for sub nodes
therefore depends on how you want to do the search for the parameter
if you want to do it in the flow of the list:
//in the loop of previous example
names.Append xq.Item(i).GetAttribute("Name")
dim xqp as xmlNodeList
xqp=xq.item(i).xql("Parameter[@Name='Focal Length (mm)']")
if xqp.length>0 then myFocalLength=xqp.item(0).getAttribute("Value")
if you want to do it from a name of a Camera and for a generic parameter:
function paramValue(xDoc as xmlDocument,cameraName as string,paramName as string) as string
dim xq as xmlNodeList
xq=xDoc.documentElement.xql("Object/Object[@Type='Camera' and @Name='"+cameraName+"']/Parameter[@Name='"+ paramName+"']")
if xq.length>0 then return xq.getAttribute("Value")
end function
This function will return the parameter string Value, note that it will be empty either for a node that does not exist or for a value intentionally blank
Sorry for being a pain but if I have a node name with forward slashes ie
@Name='./Render/Channels/Normal'
the line appears to get ignored
if its a name without slashes it works fine
I just had a look around and I can’t find anything related to this problem, :s
[quote=126152:@nige cope]Sorry for being a pain but if I have a node name with forward slashes ie
@Name='./Render/Channels/Normal'
the line appears to get ignored
if its a name without slashes it works fine
I just had a look around and I can’t find anything thing related to this problem, :s[/quote]
Yes I just realised what I was doing wrong, with C# and net I could read the parameters “on the fly” without having them in an Object group… I wasn’t looking inside the group basically
I’m on a quest to get my little Batch rendering program cross platform and I think my brain’s fried lol
originally it was written VB.Net, so I moved it to C# but I loath Mono, also QT, the problem really is I know nothing about Mac and the QT attempts was a disaster, Xojo seems the most painless way to go but yet another learning curve