Feel free to link me to something, I wasn't able to find another question like this but I'm sure I'm not framing the question correctly
I have this XML code
<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="1.0.0.2" productVersion="15.0.0" PIVersion="1.0.0.0" href="file:///C:\Users\Derek\Desktop\templates\TestForm.xsn" name="urn:schemas-microsoft-com:office:infopath:TestForm:-myXSD-2017-10-01T20-35-41" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.4"?><my:myFields xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2017-10-01T20:35:41" xml:lang="en-us">
<my:Occupation>
<my:Place_of_Work>Not Abducting People Industries</my:Place_of_Work>
<my:Salary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">10</my:Salary>
<my:Start_Date xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">1952-01-10T00:00:00</my:Start_Date>
</my:Occupation>
<my:Personal_Information>
<my:Name>Smith Johnson</my:Name>
<my:Number>123-456-7890</my:Number>
<my:Home_Information>
<my:Address>203 RealPlace Lane</my:Address>
<my:Market_Value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">10</my:Market_Value>
<my:Mortage_Paid_Off>false</my:Mortage_Paid_Off>
</my:Home_Information>
<my:Number_Of_Dependents xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">52</my:Number_Of_Dependents>
</my:Personal_Information>
<my:Description_of_Canidate>Candidate is a small man, requested loan for a bed and breakfeast startup.</my:Description_of_Canidate>
Occupation
Place_of_Work: Not abducting People Industries
Salary: 10
Start_Date: 1952-01-10 (ignore T00 its an unrelated bug )
Personal Information
Smith Johnson
123-456-7809
Home Information
Address: 203 RealPlace Lane
Market_Value: 10
Mortage_Paid_Off: false
Description of candidate: Candidate is a small man, requested loan for a bed and breakfeast startup.
int count = Regex.Matches(line1, "xmlns").Count;
String temp = line1;
List<String> namespaces = new List<string>();
int pFrom = 0;
int pTo = 0;
Boolean offset = false;
int offsetter = 0;
while (count >= 1)
{
temp = line1;
pFrom = temp.IndexOf("xmlns", pFrom + offsetter) + "key : ".Length;
pTo = temp.IndexOf("=", pFrom + offsetter);
String result = line1.Substring(pFrom, pTo - pFrom) + ":";
namespaces.Add(result);
count--;
offset = true;
if (offset)
{
offsetter = 1;
}
}
StringBuilder sb = new StringBuilder();
foreach (XmlNode node in doc.DocumentElement.ChildNodes)
{
//don't include ugly attachment string
if (node.Name != "my:File_Attachment")
{
//sb.Append(char.ToUpper(node.Name[0]));
sb.Append(node.Name);
sb.Append(" ");
sb.AppendLine(node.InnerText);
foreach (XmlAttribute attribute in node.Attributes)
{
sb.Append(" " + attribute.Name + ' ');
sb.AppendLine(attribute.Value);
}
}
}
//remove any namespaces in the XML
foreach (String NS in namespaces)
{
sb.Replace(NS, "");
String temp1 = FirstCharToUpper(NS);
sb.Replace(temp1, "");
}
Console.WriteLine(sb);
StringBuilder sb = new StringBuilder();
foreach (XmlNode node in doc.DocumentElement.ChildNodes)
{
//don't include ugly attachment string
if (node.Name != "my:File_Attachment")
{
//sb.Append(char.ToUpper(node.Name[0]));
sb.AppendLine(node.Name);
sb.Append(" ");
//sb.AppendLine();
//sb.AppendLine(node.InnerText);
foreach (XmlNode attribute in node.ChildNodes)
{
sb.Append(" " + attribute.Name + ':');
sb.AppendLine(attribute.InnerText);
//sb.AppendLine();
}
}
}
Attributes are such things:
<AgeNode Born="sadf" Salary="asdf" .../>
you have to look into child nodes ... i guess