Kevin Cabral
asked on
Get Multiple Elements on the same Leaf
Hello,
I have some XML
<exhibitor>
<primary_key/>
<company_name></company_na me>
<state></state>
<zip></zip>
<country_code></country_co de>
<contact>
<first_name></first_name>
<last_name></last_name>
<credentials/>
<phone/>
<phone_ext/>
</contact>
</exhibitor>
I Am trying to using XPath get the primary key and contact elements while keeping them in the exhibitor root node?
XmlNodeList ExhibitorNodes2 = ExhibitorsNode2.SelectNode s("exhibit or/*[self: :key_id or self::contact]");
this is just separating them and giving me the key_id and contact as a list i want them to stay in their exhibitor root?
I have some XML
<exhibitor>
<primary_key/>
<company_name></company_na
<state></state>
<zip></zip>
<country_code></country_co
<contact>
<first_name></first_name>
<last_name></last_name>
<credentials/>
<phone/>
<phone_ext/>
</contact>
</exhibitor>
I Am trying to using XPath get the primary key and contact elements while keeping them in the exhibitor root node?
XmlNodeList ExhibitorNodes2 = ExhibitorsNode2.SelectNode
this is just separating them and giving me the key_id and contact as a list i want them to stay in their exhibitor root?
ASKER
As it is now this XMLNodeList will return me primary_key, contact, primary_key, contact; I would like to rip it while keeping it in its top level exhibitor, that way the XMLNodeList is a list of exhibitors with the information inside.
You have shown us what the XML document looks like before, can you now show us what you want the result of manipulation to look like.
Also does it need to be using XPath and XmlDocument objects or are you open to Linq to XML?
Also does it need to be using XPath and XmlDocument objects or are you open to Linq to XML?
ASKER
<exhibitor>
<primary_key/>
<first_name></first_name>
<last_name></last_name>
<credentials/>
<phone/>
<phone_ext/>
</exhibitor>
this is my end goal with what was in contact being essentially out, I'm open to anything although I am working in a .net environment at this point so as long as i can pull of what i need to there i'm good.
Once i have something in the node list i'm using a set of libraries we have here internally at my place to Fill Data From XML to a dictionary then load it into SQL.
<primary_key/>
<first_name></first_name>
<last_name></last_name>
<credentials/>
<phone/>
<phone_ext/>
</exhibitor>
this is my end goal with what was in contact being essentially out, I'm open to anything although I am working in a .net environment at this point so as long as i can pull of what i need to there i'm good.
Once i have something in the node list i'm using a set of libraries we have here internally at my place to Fill Data From XML to a dictionary then load it into SQL.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you have a key_id element (primary_key ?) and contacts elements you my navigate to a root from them.
If you want some new structure you need to copy elements and link them.