© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
1 reply
reeeeeee

Parse XML response (nested path)

Currently have this:
xmlResponse = XElement.Parse(stringData);

XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlResponse.ToString());

json = JObject.Parse(JsonConvert.SerializeXmlNode(doc));
xmlResponse = XElement.Parse(stringData);

XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlResponse.ToString());

json = JObject.Parse(JsonConvert.SerializeXmlNode(doc));


Then I would like to get just that inner part of the xml
var jsonPart = json.SelectToken("FODepartment.FODepartment");
var jsonPart = json.SelectToken("FODepartment.FODepartment");

Because my XML has some inner array
FODepartment
FODepartment
with
FODepartment
FODepartment
objects (a bit weird, ik).

Is there a way to get a list of those FODepartment objects directly? Or would I need to specify a whole path (which is something like
multimap:Messages.multimap:Message2.FODepartment
multimap:Messages.multimap:Message2.FODepartment
, but I would rather have just those
FODepartment.FODepartment
FODepartment.FODepartment
if is possible)

And should I parse it in any other way, than transforming from XElement-XmlDOcument-Jobject..)
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ How to parse a json response?
C#CC# / help
4y ago
(Still) Failing to process an XML API response
C#CC# / help
17mo ago
❔ xml
C#CC# / help
4y ago