Xpath Extract data from Parent element and not its child elements where parent name is same as childXPath - extract value from parent with highest node valueXPATH for first element whose name is among the names of some other elementsFragment input xhtml to seperate xhtml files with ancestor nodes deailsHow to traverse to preceding parent node and get value of elements in XPath?xpath of elemnts including same childEffectively searching through entire 1 level nested JSONB in PostgresXSLT 2: How to wrap all content between first and last occurrence of a XML-tag?xpath: nested nodes with same nameConvert LocalDate into Timestamp in Postgres' json columnPostgreSQL occasional slow insertion speed because of FK trigger

Am I testing diodes properly?

Why do players in the past play much longer tournaments than today's top players?

Why did the Japanese attack the Aleutians at the same time as Midway?

What would the EU do if an EU member declared war on another EU member?

The monorail explodes before I can get on it

I have a ruthless DM and I'm considering leaving the party. What are my options to minimize the negative impact to the rest of the group?

Extract an attribute value from XML

Creating custom objects with custom properties using generics

Where is the USB2 OTG port on the RPi 4 Model B located?

Are randomly-generated passwords starting with "a" less secure?

Can I intentionally omit previous work experience or pretend it doesn't exist when applying for jobs?

Cops: The Hidden OEIS Substring

Was adding milk to tea started to reduce employee tea break time?

Why did my rum cake turn black?

Did any of the founding fathers anticipate Lysander Spooner's criticism of the constitution?

Is killing off one of my queer characters homophobic?

"A killed B" translation

Are there any intersection of Theory A and Theory B?

Does Google Maps take into account hills/inclines for route times?

Bronze Age Underwater Civilization

Is Arc Length always irrational between two rational points?

How can I deal with a player trying to insert real-world mythology into my homebrew setting?

Keep milk (or milk alternative) for a day without a fridge

diff shows a file that does not exist



Xpath Extract data from Parent element and not its child elements where parent name is same as child


XPath - extract value from parent with highest node valueXPATH for first element whose name is among the names of some other elementsFragment input xhtml to seperate xhtml files with ancestor nodes deailsHow to traverse to preceding parent node and get value of elements in XPath?xpath of elemnts including same childEffectively searching through entire 1 level nested JSONB in PostgresXSLT 2: How to wrap all content between first and last occurrence of a XML-tag?xpath: nested nodes with same nameConvert LocalDate into Timestamp in Postgres' json columnPostgreSQL occasional slow insertion speed because of FK trigger






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Parent and child tags have same name. I am trying to extract everything from parent except for the child elements.



We have several rows in parent that we want to extract. There are several Parent and child which are nested as below.



Have tried //Record/preceding-sibling::* which does not give me parent element start and end tag.
[not(descendant::Record)] and many other alternatives but no luck.



<Record contentId="1"> 
<Metrics_Library_Name>Text1</Metrics_Library_Name>
<Metrics_Library_ID>1</Metrics_Library_ID>
<Record contentId="1a">
<Questionnaire_ID>1a</Questionnaire_ID>
<Year>2018</Year>
<Quarter/>
<Month>02-Feb</Month>
</Record>
<Record contentId="1b">
<Questionnaire_ID>1a</Questionnaire_ID>
<Year>2018</Year>
<Quarter/>
<Month>02-Feb</Month>
</Record>
</Record>


Expected output:



<Record contentId="1"> 
<Metrics_Library_Name>Text1</Metrics_Library_Name>
<Metrics_Library_ID>1</Metrics_Library_ID>
</Record>









share|improve this question
























  • <Parent1 Record> <Text1> <Text2>...<Child1 Record><Text1></Child1> <Text2><Child2 Record>... </Child2> </Parent1 Record> <Parent2 Record> <Text1> <Text2>...<Child1 Record><Text1> <Text2></Child1><Child2 Record>...</Child2> </Parent2 Record>

    – BPM
    Mar 26 at 4:26












  • XPath selects nodes but XPath is read-only -- it cannot delete children of a selected node. Use XSLT to get the stated wanted result

    – Dimitre Novatchev
    Jun 11 at 23:38

















1















Parent and child tags have same name. I am trying to extract everything from parent except for the child elements.



We have several rows in parent that we want to extract. There are several Parent and child which are nested as below.



Have tried //Record/preceding-sibling::* which does not give me parent element start and end tag.
[not(descendant::Record)] and many other alternatives but no luck.



<Record contentId="1"> 
<Metrics_Library_Name>Text1</Metrics_Library_Name>
<Metrics_Library_ID>1</Metrics_Library_ID>
<Record contentId="1a">
<Questionnaire_ID>1a</Questionnaire_ID>
<Year>2018</Year>
<Quarter/>
<Month>02-Feb</Month>
</Record>
<Record contentId="1b">
<Questionnaire_ID>1a</Questionnaire_ID>
<Year>2018</Year>
<Quarter/>
<Month>02-Feb</Month>
</Record>
</Record>


Expected output:



<Record contentId="1"> 
<Metrics_Library_Name>Text1</Metrics_Library_Name>
<Metrics_Library_ID>1</Metrics_Library_ID>
</Record>









share|improve this question
























  • <Parent1 Record> <Text1> <Text2>...<Child1 Record><Text1></Child1> <Text2><Child2 Record>... </Child2> </Parent1 Record> <Parent2 Record> <Text1> <Text2>...<Child1 Record><Text1> <Text2></Child1><Child2 Record>...</Child2> </Parent2 Record>

    – BPM
    Mar 26 at 4:26












  • XPath selects nodes but XPath is read-only -- it cannot delete children of a selected node. Use XSLT to get the stated wanted result

    – Dimitre Novatchev
    Jun 11 at 23:38













1












1








1








Parent and child tags have same name. I am trying to extract everything from parent except for the child elements.



We have several rows in parent that we want to extract. There are several Parent and child which are nested as below.



Have tried //Record/preceding-sibling::* which does not give me parent element start and end tag.
[not(descendant::Record)] and many other alternatives but no luck.



<Record contentId="1"> 
<Metrics_Library_Name>Text1</Metrics_Library_Name>
<Metrics_Library_ID>1</Metrics_Library_ID>
<Record contentId="1a">
<Questionnaire_ID>1a</Questionnaire_ID>
<Year>2018</Year>
<Quarter/>
<Month>02-Feb</Month>
</Record>
<Record contentId="1b">
<Questionnaire_ID>1a</Questionnaire_ID>
<Year>2018</Year>
<Quarter/>
<Month>02-Feb</Month>
</Record>
</Record>


Expected output:



<Record contentId="1"> 
<Metrics_Library_Name>Text1</Metrics_Library_Name>
<Metrics_Library_ID>1</Metrics_Library_ID>
</Record>









share|improve this question
















Parent and child tags have same name. I am trying to extract everything from parent except for the child elements.



We have several rows in parent that we want to extract. There are several Parent and child which are nested as below.



Have tried //Record/preceding-sibling::* which does not give me parent element start and end tag.
[not(descendant::Record)] and many other alternatives but no luck.



<Record contentId="1"> 
<Metrics_Library_Name>Text1</Metrics_Library_Name>
<Metrics_Library_ID>1</Metrics_Library_ID>
<Record contentId="1a">
<Questionnaire_ID>1a</Questionnaire_ID>
<Year>2018</Year>
<Quarter/>
<Month>02-Feb</Month>
</Record>
<Record contentId="1b">
<Questionnaire_ID>1a</Questionnaire_ID>
<Year>2018</Year>
<Quarter/>
<Month>02-Feb</Month>
</Record>
</Record>


Expected output:



<Record contentId="1"> 
<Metrics_Library_Name>Text1</Metrics_Library_Name>
<Metrics_Library_ID>1</Metrics_Library_ID>
</Record>






postgresql-9.5 xpath-2.0






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 4:26







BPM

















asked Mar 26 at 4:16









BPMBPM

62 bronze badges




62 bronze badges












  • <Parent1 Record> <Text1> <Text2>...<Child1 Record><Text1></Child1> <Text2><Child2 Record>... </Child2> </Parent1 Record> <Parent2 Record> <Text1> <Text2>...<Child1 Record><Text1> <Text2></Child1><Child2 Record>...</Child2> </Parent2 Record>

    – BPM
    Mar 26 at 4:26












  • XPath selects nodes but XPath is read-only -- it cannot delete children of a selected node. Use XSLT to get the stated wanted result

    – Dimitre Novatchev
    Jun 11 at 23:38

















  • <Parent1 Record> <Text1> <Text2>...<Child1 Record><Text1></Child1> <Text2><Child2 Record>... </Child2> </Parent1 Record> <Parent2 Record> <Text1> <Text2>...<Child1 Record><Text1> <Text2></Child1><Child2 Record>...</Child2> </Parent2 Record>

    – BPM
    Mar 26 at 4:26












  • XPath selects nodes but XPath is read-only -- it cannot delete children of a selected node. Use XSLT to get the stated wanted result

    – Dimitre Novatchev
    Jun 11 at 23:38
















<Parent1 Record> <Text1> <Text2>...<Child1 Record><Text1></Child1> <Text2><Child2 Record>... </Child2> </Parent1 Record> <Parent2 Record> <Text1> <Text2>...<Child1 Record><Text1> <Text2></Child1><Child2 Record>...</Child2> </Parent2 Record>

– BPM
Mar 26 at 4:26






<Parent1 Record> <Text1> <Text2>...<Child1 Record><Text1></Child1> <Text2><Child2 Record>... </Child2> </Parent1 Record> <Parent2 Record> <Text1> <Text2>...<Child1 Record><Text1> <Text2></Child1><Child2 Record>...</Child2> </Parent2 Record>

– BPM
Mar 26 at 4:26














XPath selects nodes but XPath is read-only -- it cannot delete children of a selected node. Use XSLT to get the stated wanted result

– Dimitre Novatchev
Jun 11 at 23:38





XPath selects nodes but XPath is read-only -- it cannot delete children of a selected node. Use XSLT to get the stated wanted result

– Dimitre Novatchev
Jun 11 at 23:38












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349769%2fxpath-extract-data-from-parent-element-and-not-its-child-elements-where-parent-n%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349769%2fxpath-extract-data-from-parent-element-and-not-its-child-elements-where-parent-n%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현