using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Xml;
public class XmlReader : MonoBehaviour
{
XmlDocument doc = new XmlDocument();
// Use this for initialization
void Start ()
{
doc.Load(@"C:\Users\myxml\Documents\mysvg.svg");
XmlNode node = doc.DocumentElement.SelectSingleNode("/g");
foreach (XmlNode nodes in doc.DocumentElement.ChildNodes)
{
string text = nodes.InnerText; //or loop through its children as well
}
}
// Update is called once per frame
void Update ()
{
}
}
I want to get all the children under <g>
Then to parse each child to array for example:
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="opacity:1;fill:#00c8fc;fill-opacity:0.98823529;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4155"
width="45.714287"
height="30"
x="37.387959"
y="115.30345" />
<rect
style="opacity:1;fill:#00c8fc;fill-opacity:0.98823529;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4155-5"
width="45.714287"
height="30"
x="91.899246"
y="115.40621" />
So i want to create array call it Rects
Maybe string[] Rects;
Then under each Rect in the array to have his parameters also as strings:
Rect1
fill:#00c8fc
width="45.714287"
height="30"
x="37.387959"
y="115.30345"
This format.
So then i can get access from another script to Rect1 and his parameters like:
Rect1.width
... or Rect1.x
....Rect1.fill
....