Convert FBX to to xml using C# - c#

I just want to make a simple windows form application that allows the user to select a .fbx file and then it will save as an XML file. I know how to use the select file dialog and XML serialization. Just stumped when it comes the FBX handling. I just need the Verts, triangles and first UVs. No animations or materials.
Anyway Here's the XML format I need:
<?xml version="1.0" encoding="utf-8"?>
<MeshInformation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<verts>
<Info_Vector3>
<x>8.785349</x>
<y>7.7458005</y>
<z>1.65082479</z>
</Info_Vector3>
<Info_Vector3>
<x>8.785349</x>
<y>0.427168041</y>
<z>1.65079832</z>
</Info_Vector3>
// etc...
</verts>
<triangles>
<int>0</int>
<int>1</int>
<int>2</int>
<int>0</int>
// etc...
</triangles>
<uvs>
<Info_Vector2>
<x>8.785349</x>
<y>0.427168041</y>
</Info_Vector2>
// etc...
<uvs />
</MeshInformation>

Related

Read a section in FHIR Document Reference Data

Is there any way to read a CCD Data section inside the CCDA XML using FhirSerialization in R4.
I have a DocumentReference FHIR Object and in that I have DATA section in a byte format. I have converted it to a string using the below line.
string decodedSamlRequest = System.Text.Encoding.UTF8.GetString(dfv);
and now in this decodedSamlRequest I have the CCD XML content.
<?xml version="1.0" encoding="UTF-8"?>
<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="xyz" xmlns:sdtc="xyz" xmlns:xsi="xyz">
<realmCode code="US"/>
<assignedCustodian>
<representedCustodianOrganization>
<id root="123" extension="92"/>
<name>some xyz</name>
<telecom use="WP" value="tel:1234"/>
<addr use="WP">
<streetAddressLine>address</streetAddressLine>
<city>city</city>
<state>state</state>
<postalCode>12345</postalCode>
<country>US</country>
</addr>
</representedCustodianOrganization>
</assignedCustodian>
</custodian>
</ClinicalDocument>
In this I need to read the CITY element under Custodian Tag.
From FHIR's perspective, all content within an attachment is opaque. You can certainly write code to parse, access and manipulate that content - and could even create custom SearchParameters that could filter based on it. But you can't navigate into it using FHIRPath or using the navigation machinery found in any of the reference implementations.

How to change xml element value in c#?

<?xml version="1.0" encoding="utf-8"?>
<Settings>
<Code>D:picture\simple</Code>
<Password>picture</Password>
</Settings>
I want to change the value which is inside Code and Password.How can I change the value.
XElement root = XElement.Load("path/to/xml/somewhere");
root.Element("Code").Value= "newcode";
root.Element("Password").Value ="Penis *gnhihihi*";
//only in Linqpad
root.Dump();
And there you have it. This is one way to change it.
It is up to you how you save it back to an xml file

how to add uri of lexicon file in xml

I am writing code for custom grammar for that I created a lexicon file which I am using in XML grammar file. I want to add the lexicon with my software to the end user as an embedded resources so how can i reference it's uri in XML?
my XML codes are
<?xml version="1.0" encoding="utf-8"?>
<grammar
version="1.0" mode="voice" root="Voice_Automator"
xml:lang="en-IN" tag-format="semantics/1.0"
sapi:alphabet="x-microsoft-ups"
xml:base="http://www.contoso.com/"
xmlns="http://www.w3.org/2001/06/grammar"
xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions">
**<lexicon uri="C:\Users\Agrawal\Documents\Visual Studio 2010\Projects\123.pls" />**
i want to use 123.pls file as an embedded resource so at the end user the program should load it properly
Use one of the XML link mechanisms:
XLink
<lexicon xmlns:link="http://www.w3.org/1999/xlink" xlink:href="C:\Users\Agrawal\Documents\Visual Studio 2010\Projects\123.pls"/>
External Entity
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE foo [<!ENTITY bar SYSTEM "C:\Users\Agrawal\Documents\Visual Studio 2010\Projects\123.pls"> ]>
<grammar version="1.0" mode="voice" root="Voice_Automator" xml:lang="en-IN" tag-format="semantics/1.0" sapi:alphabet="x-microsoft-ups" xml:base="http://www.contoso.com/" xmlns="http://www.w3.org/2001/06/grammar" xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions">
<? &bar; ?>
</grammar>
References
XML Linking Language
XML Linking and Style
XML: How to read one file into another
XML: How to load the contents of one xml file into another
How do I check for the existence of an external file with XSL?
how to use xpointer to link to specific node from another document
Generate HTML / Help files from VS 2010 C# XML documentation

C# Open, Edit then Save XML to File

How would I go about editing this XML file:
<?xml version="1.0" encoding="utf-8" ?>
<employees>
<employee id="657434365436543" name="Joe Bloggs" group="Manager" subgroup="Deputy">
<contactDetails>
<homePhone>6535436543</homePhone>
<mobilePhone>654365436543</mobilePhone>
</contactDetails>
<personelFile>
<rightToWork>
<type>Permanent</type>
<expires>Never</expires>
</rightToWork>
<nationalInsurance>6543655543</nationalInsurance>
<startDate>01/09/2009</startDate>
</personelFile>
<holidays>
<entitlements>
<holidays>22</holidays>
<bankHolidays>8</bankHolidays>
<personalDays>1</personalDays>
</entitlements>
<taken>
<holidays>1</holidays>
<bankHolidays>0</bankHolidays>
<personalDays>0</personalDays>
</taken>
<remaining>
<holidays>21</holidays>
<bankHolidays>8</bankHolidays>
<personalDays>1</personalDays>
</remaining>
<booked>
<holidays>22</holidays>
<bankHolidays>8</bankHolidays>
<personalDays>1</personalDays>
</booked>
<remainingtobook>
<holidays>0</holidays>
<bankHolidays>0</bankHolidays>
<personalDays>0</personalDays>
</remainingtobook>
</holidays>
<shifts>
<monday>
<start>0800</start>
<end>1300</end>
</monday>
<tuesday>
<start>0800</start>
<end>1300</end>
</tuesday>
<wednesday>
<start>0800</start>
<end>1300</end>
</wednesday>
<thursday>
<start></start>
<end></end>
</thursday>
<friday>
<start>0800</start>
<end>1300</end>
</friday>
<saturday>
<start>0800</start>
<end>1200</end>
</saturday>
<sunday>
<start></start>
<end></end>
</sunday>
</shifts>
</employee>
</employees>
So far I have the following to select the correct employee from the XML:
XmlTextReader employeesReader = new XmlTextReader("Employees.xml");
var employeesXdoc = XDocument.Load(employeesReader);
var employees = from employee in employeesXdoc.Descendants("employee")
where employee.Attribute("id").Value.ToString() == employeeSelect.Value.ToString()
select new
{
nodes = employee.Nodes()
};
foreach (var employee in employees)
{
// WHAT TO PUT HERE?
}
I'm guessing I've found the right place to insert the editing for the file but then I need to know how to correctly edit it and then save it to the file without losing everything else contained there (otherwise I'd just overwrite the whole file.
Thanks for any help.
A good idea is also to use the xml-serializer-class.
There you can work with usual objects and save it to the xml later :)
http://msdn.microsoft.com/en-us/library/ms733901.aspx
Here is a useful link for updating an XML file without rewriting it in its entirety on each save:
http://support.microsoft.com/kb/301233
the general idea is to use a XMLDocument instead of a XMLTextReader and load your .xml file into the XMLDocument object. then grab the root node and start navigating/querying. once you have found the nodes you wish to edit, make your changes. then when you are done, use XMLDocument.Save(path) to save your chagnes.
IO streams are one way phenoma so you can;t use an reader/writer unless you want to overwrite the existing file.

Reading a template and creating a new XML file using the read template

I'm attempting to read a XML template, code below, and put this content to a new XML file.
<?xml version="1.0" encoding="utf-8"?>
<Format>
<Name title=""></Name>
<FormatA>
<Scheme name="A" set="number" get="integer">
<Sample set="number" get="integer">33</Sample>
</Scheme>
</FormatA>
<FormatX>
<Scheme name="A" set="number" get="integer">
<Sample set="number" get="integer">44</Sample>
</Scheme>
</FormatX>
</Format>
And will input values and write the title and a value for name. e.g When I enter "Counter" for the title and "Cnt" for the value. It will write
<Name title="Counter">Cnt</Name>
Basically, I'll just copy the contents of the template, put it in the new XML file with the inputted title and value.
Thank you for reading and who will answer my inquiry.
Did you tried string.Format?
Create the Template XML file with
Place Holders, like this {1}
Call
String.Format(XmlContent,"Counter","Cnt")
Hope it helps.

Categories

Resources